Page 1 of 1

[SOLVED] change url in variable

Posted: Wed Mar 21, 2007 9:24 am
by ddragas
Hi all

I' need to change link inside variable with another link

example

$some_text = 'some text some text some text some text <a href=\"http://www.someurl.com/somedirectory/so ... php\">some text</a> some text some text some text <a href=\"http://www.someotherurl.com/someotherdi ... php\">some text</a> some text';


for each links in $some_text should be replaced with "http://" . $_SERVER['HTTP_HOST'] . /stranice/preg_str.php


if somebody coul point me in right direction

regards

ddragas

Posted: Wed Mar 21, 2007 9:33 am
by feyd
I'm pretty sure there's been a few threads in Regex that have talked about your problem.

Posted: Wed Mar 21, 2007 9:48 am
by ddragas
thank you for reply

wrong forum

could this post be moved to Regex, so there would not be double posted threat?

Thank you

Posted: Wed Mar 21, 2007 9:52 am
by feyd
Look for a thread pertaining to your problem first please.

Posted: Thu Mar 22, 2007 2:38 am
by ddragas
I've used search, but with no success :cry:

whatI'm trying to accomplish is:
- separate link from other text inside variable and put it in new variable
- if in new variable is some text (if (stristr($MY_SELF, "/FCKeditor/File/")))
- take name of file from link (basename) (some html file)
- read content of that file (certain number) (file_get_contents)
- change link with new link (str_replace)


As you can see I'm missing only first part (separate link from other text inside variable)


how can I do it?