drifter Posted December 12, 2006 Share Posted December 12, 2006 I have a page that I got from file_get_contents.I want to replace all href="/some/page/here.php?with=a&query=string" with something likehref="http://mydomain.php?page=http://originaldomain.com/some/page/here.php?with=a&query=string"obviously this all needs to be urlencoded(http://originaldomain.com/some/page/here.php?with=a&query=string)is there an easy way to do this? Do I need to do a preg_match then look through all matches and do a str_replace on each one?thanks Scott Quote Link to comment https://forums.phpfreaks.com/topic/30286-url-replace/ Share on other sites More sharing options...
Ninjakreborn Posted December 12, 2006 Share Posted December 12, 2006 url_decode Quote Link to comment https://forums.phpfreaks.com/topic/30286-url-replace/#findComment-139428 Share on other sites More sharing options...
JasonLewis Posted December 12, 2006 Share Posted December 12, 2006 i am not sure thats wat they are asking for... :Si think they want to no if there is a way of looping through all the text from the file they got the contents from and replacing any specified links with a new link. Quote Link to comment https://forums.phpfreaks.com/topic/30286-url-replace/#findComment-139429 Share on other sites More sharing options...
drifter Posted December 12, 2006 Author Share Posted December 12, 2006 got it - I did a preg_match_allthen a foreach on the matches with a urlendcode of the new URLs then a str_replace Quote Link to comment https://forums.phpfreaks.com/topic/30286-url-replace/#findComment-139431 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.