• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

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
0
jwfranklin
Asked:
jwfranklin
  • 2
1 Solution
 
ddrudikCommented:

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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now