首页 > 技术文章 > php把数组写入文件

yanweifeng 2020-04-15 10:11 原文

$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 '创建失败';
}

推荐阅读