Can anyone tell me why this part of my code is not functional? The code might be quite messy to look at, but I've commented wherever I can.
$gp = fopen("myFile.txt","r"); while(($t = fgets($gp,1024)) && !feof($gp)) { if ($t[0] == '=' && $t[1] == 'D') { \\Looks for =D in myFile.txt $entryDate[] = fgets($gp,30); \\then takes next line and } elseif ($t[0] == '=' && $t[1] == 'A') { \\puts it into $entryDate[] $entryAuth[] = fgets($gp,50); } elseif ($t[0] == '=' && $t[1] == 'C') { \\With a =C in myFile.txt $readAll = fread($gp,1024); \\it reads 1024 characters & $readAll = str_replace(" \\replaces all newlines ", "<BR CLEAR=ALL>", $readAll); \\ with a HTML tag. $endPoint = strpos($readAll,"^end"); \\Detects the position of ^end $readTil = $endPoint - 1; \\ and outputs $readTil $entryCont[] = substr($readAll,0,$readTil); \\ content to this point } else { /* Nothing to be done, go back to beginning of while */ } } The problem is that it doesn't actually go back to the beginning of the while loop. I've checked the array counts for the $entryDate[] array and it always tells me that I have only 1 entry, even though myFile.txt has 2 or more entries. So it doesn't seem to go anywhere. When I replace the part after checking for =C with a simple fgets (like the other 'if' parts of the code), it works perfectly. Something in the functions after the if( .... =C) is stopping the while loop and I don't know what it is! Note: It does execute all the functions after the if(... =C), because the $entryCont[] array contains all the formatted/substituted text. Please help? -Wendy ------------------------------------------------- This mail sent through IMP: www-mail.usyd.edu.au -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php