📜  php 将数组保存到文件 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:16.382000             🧑  作者: Mango

代码示例1
$arr1 = array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5);
file_put_contents("array.json",json_encode($arr1));
# array.json => {"a":1,"b":2,"c":3,"d":4,"e":5}
$arr2 = json_decode(file_get_contents('array.json'), true);
$arr1 === $arr2 # => true