php把数组写入文件

$file='./array.php';
$map = [
6566 => ['2020-01-02', '2020-01-03'],
6567 => ['2020-01-02', '2020-01-03'],
6568 => ['2020-01-02', '2020-01-03'],
];
$text='<?php '.PHP_EOL.' return '.var_export($map,true).';';
if(false!==fopen($file,'w+')){
file_put_contents($file,$text);
}else{
echo '创建失败';
}

原文地址:https://www.cnblogs.com/yanweifeng/p/12703477.html