I want to replace this url, before array gets inserted in mysql table.
I have title description and link in array, and link has too much “junk”
Here is sample of what var_dump($item[“link”]); looks like:
[“link”]=> string(88) “http://www.hello.com/junk/junk-ju-junkj-junk-jun-ju-junk,-JU-1234”
I would like to get link replaced like this:
[“link”]=> string(88) “http://www.hello.com/te/tst?te=1234”
So search everything between “http://www.hello.com” and “very last ‘-‘ …before 1234”
and replace it with “/te/tst?te=”
How do I replace this before it gets inserted in mysql table?
Thank you in advance for your expertise and time 😉
Do you anticipate other top-level domains other than ‘com’? Assuming
You can do
You’ll get