存数组:
<?php
$data = array(
"a" => "aaaaaa",
"b" => "bbbbb",
"c" => "ccccc",
"d" => "dddddd",
"e" => "eeeeee",
"f" => "ffffff",
"g" => "ggggggg",
"h" => "hhhhhh",
"i" => "iiiiiiii",
);
$path = "static_data.php";
$str = "<?php\nreturn " . var_export($data, true) . ";\n";
file_put_contents($path, $str);
可以不用return
直接调用变量名就行
取数组:
<?php
$data = include 'static_data.php';
echo "<pre>";
var_dump($data);
var_dump($data['a']);