배열 변수 값 내에있는 변수 값을 업데이트하려고합니다.PHP에서 배열 변수 값 내의 변수 값을 변경하십시오.
나는 파일을 쓰고있는 것을 볼 것이다 : file_put_contents()
. implode("\r\n", $contents)...
에는 $contents
변수가 들어 있습니다.
$body_file_count
에서 변수 값을 업데이트 할 수 없습니다 꽤 분명 년대
if ($i == $per_file) {...
의 모든 반복을 증가시킬 $body_file_count
이 필요합니다.
$body_file_count
은 출력되는 파일 수입니다. 실제로 파일 제목에서 같은 수의 : $file_count
...
기본적으로, 난 그냥에 $body_file_count
를 작성해야합니다 : 각각의 경우 ($i == $per_file) {
반복에
$default_contents=$contents=array("BODY CONTENT TOP . "$body_file_count" . ");
. 분명히 $body_file_count
을 스크랩하면 $ file_count를 $content
에 전달할 수 있습니다. $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()
나는 이것을 이미 시도한 것으로 생각했지만 if 반복의 끝에 $ 내용을 두지 않았다. 지금 $ file_count OK를 출력하고있는 것으로 보입니다. 제안 해 주셔서 감사합니다. – OldWest