php 将数组原样放进文件
$arr = [
'key1' => 'value1',
'key2' => 'value2',
];
$content = "<?php\nreturn " . var_export($arr, true) . "\n?>";
file_put_contents('./test.php', $content);
<?php
return array (
'key1' => 'value1',
'key2' => 'value2',
)
?>