preg_match_all problem

From: Date: Tue, 02 Nov 2004 00:22:36 +0000
Subject: preg_match_all problem
Groups: php.general 
Request: Send a blank email to php-general+get-200894@lists.php.net to get a copy of this message
Hi, Below is my code for a templating kind of script, it basically searches for 'tags' like this {movies 30} and replaces them, the problem is that if there are 2 tags (eg: {movies 30}{movies 60}) it only replaces the first one...so I tried using a preg_match_all... I tried using a preg_match_all at: preg_match($pattern,$content,$matches[]); but then $res is blank when $res usually contains the tag names... (using a print_r($res); I just get Array ( [0] => Array ) ) ******Start of code********* $categories=array("movies","action","cartoons","textlinks"); // This gets the tags and put it into matches[] foreach ($categories as $value) { $pattern = "/{".$value." ([0-9_]+)?}/"; preg_match($pattern,$content,$matches[]); } foreach ($matches as $key =>$value){ preg_match("/\w+/",$value[0],$res); //print_r($res); *******End of code********* What am I doing wrong? Thanks, Ryan

« previous php.general (#200894) next »