I think fgets() will pull your \n off the end of the line, so make sure your regular expression isn't expecting it if you are doing it this way.
M On Wed, Jan 7, 2009 at 6:01 PM, Michael <[email protected]> wrote: > > On Wed, 07 Jan 2009 15:41:44 Steve Boyd wrote: >> $fh = fopen('data.txt'); >> while ($line = fgets($fh)) { >> preg_match(...,$line); ... >> } >> fclose($fh); > > The issue is with this code, is while it reads the whole file, the array out > put of preg_match_all is empty. (note that preg_match also returns empty). > > $fh = fopen($filename,"r"); > while ($content = fgets($fh)) { > > preg_match_all($pattern,$content,$matches); > > } > fclose($fh); > > print_r($matches); > exit(); > > OUTPUT OF PRINT_R() > > Scanning files: Array > ( > [0] => Array > ( > ) > > [1] => Array > ( > ) > > [2] => Array > ( > ) > > ) > > > > --~--~---------~--~----~------------~-------~--~----~ NZ PHP Users Group: http://groups.google.com/group/nzphpug To post, send email to [email protected] To unsubscribe, send email to [email protected] -~----------~----~----~----~------~----~------~--~---
