Matching a breadcrumb style URL

Hello

I need to do a regex replace of a URL for example:

http://localhost/index.php?page=About_Us&page=Our_Address&page=Map

this needs to be re-written as:

http://localhost/About_Us/Our_Address/Map

Does anyone know how this can be done for multiple instances of page=?

Thanks

Jonathan
LVL 1
jwfranklinAsked:
Who is Participating?
 
ddrudikConnect With a Mentor Commented:

echo preg_replace('#(?<=^http://localhost)[^?]*\?page=|&page=#','/',$sourcestring);

Open in new window

0
 
jwfranklinAuthor Commented:
Spot on, that works fine. Thanks
0
 
ddrudikCommented:
Thanks for the question and the points.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.