Re: preg_match fails to fill $matches

From: Date: Wed, 05 Mar 2003 17:06:41 +0000
Subject: Re: preg_match fails to fill $matches
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-138308@lists.php.net to get a copy of this message
> >What's your actual code? How are you looking for the match in $matches? > >If something was matched, then it'll be there. > > The full cod in the loop is. > > $cnt = 0; > while(!feof($fp)) > { > // Get body > $line_in = fgets($fp,4096); > $cnt++; > // looking for the other end of the marker found above > if (substr($line_in,2,strlen($line_in)-5) != $marker ) > { > $body = $body . $line_in; > $hit[] = preg_match ($ts, $line_in,$matches); > $line[] = $line_in; > $char = substr($line_in,0,1); > $quote[] = preg_match ($qs, $char); > } > if (strpos($line_in, $marker) > 0 ) { > break; > } > } > > Later on in the code after the loop I do > > echo "printing array matches <br>"; > print_r ($matches);echo "<br>"; $matches is going to be over-written after every time through the loop! It doesn't add it all up. Add in a $var[] = $matches; or something inside of your loop to keep track of them all, then print_r($var) to see what it contains. ---John Holmes...

« previous php.general (#138308) next »