I have a piece of code as below:
ini_set("display_errors", "1");
error_reporting(E_ALL);
$i = 0;
do {
$filename = "links".DIRECTORY_SEPARATOR . $i++ . "-WriteURLs.txt";
} while (file_exists($filename));
$write_URLs = fopen($filename, "w");
foreach ($list_URLs as $htmlIndividual) {
GetURLs ($htmlIndividual);
foreach ($URLs as $URLK) {
fwrite($write_URLs, $URLK ."\n");
}
echo "Hello World (Inside Foreach Loop) <br>";
}
echo "Hello World (First Foreach Loop) <br>";
fclose($write_URLs);
$trimmed = explode("\n",file_get_contents($filename));
foreach ($trimmed as $URLSa) {
echo "Hello World (Second Foreach Loop) <br>";
}
The code writes the URLs to 0-WriteURLs.txt, 1-WriteURLs.txt, 2--WriteURLs.txt and ... and echos the below on every execution of the code:
Hello World (Inside Foreach Loop)
Hello World (Inside Foreach Loop)
But, as you can see, the code stops executing the codes after the first foreach loop and it can not echo the Hello World (First Foreach Loop) and Hello World (Second Foreach Loop) accordingly. Could you please let me know how I can solve this problem? thanks
Note: I added error_reporting = E_ALL to php.ini file and increased memory limit to memory_limit = 256M, but still there is no change.
error_reporting = E_ALLto php.ini file, but still no change,Hello World (First Foreach Loop)is not even inside of a loop