[SOLVED] change url in variable

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

Post Reply
User avatar
ddragas
Forum Contributor
Posts: 445
Joined: Sun Apr 18, 2004 4:01 pm

[SOLVED] change url in variable

Post 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
Last edited by ddragas on Fri Mar 23, 2007 6:41 am, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I'm pretty sure there's been a few threads in Regex that have talked about your problem.
User avatar
ddragas
Forum Contributor
Posts: 445
Joined: Sun Apr 18, 2004 4:01 pm

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Look for a thread pertaining to your problem first please.
User avatar
ddragas
Forum Contributor
Posts: 445
Joined: Sun Apr 18, 2004 4:01 pm

Post 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?
Post Reply