I have a big string with a lot of URLs, I need to replace the URLs that match:
<a href="../plugins/re_records/somefile.php?page=something&id=X">important_name</a>
(where X
is an any integer and important_name
is any string) with:
<a href="/map/important_name">important_name</a>
I'm using preg_match_all()
to match all URLs:
preg_match_all('/\/plugins\/re\_records\/somefile\.php\?page\=something\&id\=*(\d+)/', $bigString, $matches, PREG_OFFSET_CAPTURE);
The problem is that I don't understand how to get the important_name
from the hyperlink's visible text to become part of the new url after the URL match.
Is it a good idea to use preg_match_all()
?