我想使用file_put_contents().
$arr= array('red');
$content= "<?php \n$".$var."=".$arr."\n?>";
file_put_contents('file.php', $content);
但是如果我打開file.php我讀到這個:
<?php
$var=Array
?>
我想看看 array('red')
我也試過,serialize()但輸出很糟糕......
uj5u.com熱心網友回復:
將陣列轉換為字串只會回傳Array. 您可以使用var_export()來獲取要在那里使用的陣列文字。
$content = "<?php \n\$" . $var . "=" . var_export($arr, true) . "\n?>";
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/334113.html
