Re: REGEX

From: Date: Mon, 15 Jan 2001 07:13:13 +0000
Subject: Re: REGEX
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-34576@lists.php.net to get a copy of this message
First, the ()'s in the split regex makes no sense. Split has no registers to save stuff to. Second, that is a rather clunky way to loop through an array. Third, since the regex in split defines the delimiter to use to split the string on, the actual "1 -->" part of the data is gone. Why are you checking for it via an ereg() call in the loop? As far as I can tell, you simply want this: $buffer = split("[0-9] -->",$pagedata); foreach($buffer as $val) echo "$val<br>\n"; But then again, I don't really know what you are trying to do here. -Rasmus On Mon, 15 Jan 2001, Romulo Roberto Pereira wrote: > Hey people! > > What is wrong with this code? > > $buffer = split("([0-9] -->)",$pagedata); > $x = count ($buffer); > echo $x; > for ($i=0;$i<$x;$i++) { > ereg("([0-9] -->)", $buffer[$i], $text); > ereg_replace (" -->","", $text[1]); > echo $text[1]; > } > > Since $pagedata has 8 appearences of the REGEX I am looking for and it is > only printing the first one... > > Help! ;-) > > Thank you, > > Rom > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#34576) next »