如题,代码如下:
$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',
)
?>
如题,代码如下:
$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',
)
?>