PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
barak
Forum Newbie
Posts: 2 Joined: Tue May 20, 2008 6:25 am
Post
by barak » Fri Jun 27, 2008 8:20 am
Hi,
I have some problems with getting the address from a <A> tag.
I made this little function:
Code: Select all
function href_d($string)
{
preg_replace("#<a[?: href=('|\")((\w:/\.\?\#&=\-)*)\\2]?[\w\"'_\s]*>#iU","1 \\2",$string);
htmlspecialchars($string);
return $string;
}
but...
There is some error.
Its retrieving me the same string i entered.
Any one see the problem?
Ty
Stryks
Forum Regular
Posts: 746 Joined: Wed Jan 14, 2004 5:06 pm
Post
by Stryks » Fri Jun 27, 2008 8:56 am
I cant remember ... does preg_replace actually modify the subject string, or just return a modified copy?
Perhaps ...
Code: Select all
$new_string = preg_replace("#<a[?: href=('|\")((\w:/\.\?\#&=\-)*)\\2]?[\w\"'_\s]*>#iU","1 \\2",$string);
return htmlspecialchars($new_string);