...

View Full Version : Problems with preg_replace..



cyphix
05-04-2006, 02: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?

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

cyphix
05-04-2006, 09: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