- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
function array_to_file($array_name, $array, $filename = 0, $file = 0)
{
$level = 1;
if($file == 0) {
$level = 0;
$file = fopen($filename, "w");
if(!$file) {
return false;
}
fwrite($file, "<" . "?\n\$".$array_name." = ");
}
$cnt = count($array);
$i = 0;
fwrite($file, "\narray(\n");
foreach($array as $key => $value)
{
if($i++ != 0) {
fwrite($file, ",\n");
}
if(is_array($array[$key])) {
fwrite($file, "\"".$key."\" => ");
array_to_file($array_name, $array[$key], 0, $file);
} else {
$value = addcslashes($value, "\""."\\\\");
fwrite($file, str_repeat(" ", ($level + 1) * 2) . "\"".$key."\" => \"".$value."\"");
}
}
fwrite($file, ")");
if($level == 0) {
fwrite($file, ";\n?".">");
fclose($file);
return true;
}
}
Fike 02.07.2015 14:07 # 0
Fike 02.07.2015 14:11 # 0