我想将数组的内容写入新文件。foreachloop中的Fwrite PHP
只要它站立我的文件只包含我的数组的最后一个元素,而不是前两个。所以文件output2.txt中的文本只有Edward。
我在这里误解了一些东西吗?
<?php
$array = array ("Sarah", "William", "Edward");
foreach ($array as $value) {
$myfile = fopen("output2.txt", "w") or die("Unable to open file!");
fwrite($myfile,$value);
fclose($myfile);
}
?>
更多efficency内爆数组环比它 – 2016-04-30 11:33:44