我正在尝试更新数组变量值内的变量值。
你会看到我正在写出一个文件:file_put_contents(). implode("\r\n", $contents)...包含$contents变量。
我需要$body_file_count增加if ($i == $per_file) {...
很明显 $contents 数组在这种情况下无法更新变量值$body_file_count。
$body_file_count是输出的文件数。它实际上是文件标题中的相同数字:$file_count...
基本上,我只需要写到$body_file_count:
$default_contents=$contents=array("BODY CONTENT TOP . "$body_file_count" . ");
在每次 if($i == $per_file) {迭代中。显然,$body_file_count如果我可以将 $file_count 传递给$contentas$file_count按预期更新标题,我可以报废。
$body_file_count = 0;
$footer = "FOOTER";
$default_contents = $contents = array("BODY CONTENT TOP . "$body_file_count" . ");
while ($row = mysql_fetch_array($result)) {
$line = "...";
$contents[] = $line; // Each array element will be a line in the text file
$i++;
$recs++;
if ($i == $per_file) {
$contents[] = $footer; // Add the footer to the end
file_put_contents($_POST["a"] . "-#" . $file_count . "-" . date('Y') . "-" . $_POST["b"] . "-" . $recs . "-" . $txtdate . '.txt', implode("\r\n", $contents));
$i = 0;
$recs = 0;
$contents = $default_contents;
$file_count++;
$body_file_count++;
} // End of if()
} // End of while()