preg_match_all problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux