Reputation: 11
I have this html tag
<a href="<navigation>3</navigation>">Go Here</a>
I want to find any and all references to <navigation></navigation>
, retrieve the int value thats between the <navigation>3</navigation>
(in this case the number 3), run an sql query and return a record where the id is the value between <navigation>3</navigation>
(again in this case 3) and replace the entire tag with whatever was returned from the sql query.
note: there could be more than one navigation tag within my string. plus a bunch of other html. i want to keep all the other and find, build, and replace new text where the navigation tag is.
Upvotes: 1
Views: 75
Reputation: 2093
You can use preg_replace_callback. You can search for <navigation>\d+</navigation>
and change it in the callback function.
Upvotes: 3