|  | Posted by Daniel Tryba on 06/13/97 11:20 
Sugapablo <russ@removesugapablo.com> wrote:> We can assume that the tags will always be written properly.
 
 So why did you make an error in your example? :)
 
 [string]
 > ...I'd need the code to return, probably an array, like this:
 > $array[0] = Allegheny River
 > $array[1] = PNC Park
 > $array[2] = 37,259
 >
 >
 > I just can't get it.  Any suggestions?
 
 Tell us where you are running into problems. It's really simple if:
 -you know the correct function
 -you know your regexpes.
 
 Do you want to learn how to do it or do you just want the answer of how
 to get an array like:
 
 Array
 (
 [0] => Array
 (
 [0] => <tag class="name">Allegheny River</tag>
 [1] => <tag class="name">PNC Park</tag>
 [2] => <tag class="name">37,259</tag>
 )
 
 [1] => Array
 (
 [0] => Allegheny River
 [1] => PNC Park
 [2] => 37,259
 )
 )
 
 If you want to learn see
 http://nl2.php.net/manual/en/function.preg-match-all.php (the examples
 contain samples that match your question closely) and
 http://nl2.php.net/manual/en/reference.pcre.pattern.syntax.php (study
 greedy vs. non greedy)
 
 The spoiler is below:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 preg_match_all('/<tag class="name">(.*?)<\/tag>/',$str,$matches);
  Navigation: [Reply to this message] |