View Full Version : Problems with preg_replace..

05-04-2006, 01:09 PM
Hey guys.... I'm using this code:

$cat_names[] = preg_replace('~.*<li><a href="/search\.php\?cat=1">(.*?)</a></li>.*~is', "$1", $main_line);

Now...... shouldn't it be returning what is between the <a></a> tags (The name of the link)? Problem is...... it's returning the whole line.

Any help?

05-04-2006, 01:13 PM
preg_match_all('/<li><a href="/search.php[^"]+">(.*?)</a></li>/is', $lines, $matches);
$matches[1] should be an array of the link contents.

05-04-2006, 08:35 PM
Thanks...... I got my original code working tho..... the code on the page had changed slightly & now that I adjusted it works fine. :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum