Function returns a string in ereg_replace()
Posted: Tue Jul 15, 2003 10:52 am
Hi,
Let's say that I want to create a html tag from the url parsed to script from a textarea. The url could point on www page -> like http://www.wp.pl , attachement -> http://www.somesite.com/attachment.zip or img -> http://www.somesite.com/picture.jpg. Depending on what url points on the function should return typical '<a href' or '<img src' stuff. I wrote the function and it's doing great so there's no problem with that.
The problem is how to parse the url to that function from ereg_replace()
I've tried the following:
But it's obvious that it doesn't work properly. Could you tell me why how to correct this (if that's possible) or what I should read to learn more about this. (I've looked in the php.net - but maybe not good enough)
I would be very gratefull.
Let's say that I want to create a html tag from the url parsed to script from a textarea. The url could point on www page -> like http://www.wp.pl , attachement -> http://www.somesite.com/attachment.zip or img -> http://www.somesite.com/picture.jpg. Depending on what url points on the function should return typical '<a href' or '<img src' stuff. I wrote the function and it's doing great so there's no problem with that.
The problem is how to parse the url to that function from ereg_replace()
I've tried the following:
Code: Select all
$html_tag = ereg_replace("[[]]+://[^<>[]]+[[]/]",
create_tag_from_url("\\0"), $textarea_content);I would be very gratefull.