I get the product pictures from a supplier in a csv file with addresses like below:
most of the url are fine and easy to replace with a simple replace:
- supplier.com/images/ref_1.png
becomes
- mywebsite.com/media/tires/ref_1.png
with
$URL_photo = str_replace( "supplier.com/images/", "mywebsite.com/media/tires/", $URL_photo
but I have also some urls from my supplier which include subfolders paths
- mysupplier.com/images/c/brand1/ref_1.jpg
- mysupplier.com/images/c/brand2/ref_27.jpg
- mysupplier.com/images/09/ref_300.png
- mysupplier.com/images/cd/ref_10.png
How to regex or replace to get the same simpler url ?
mywebsite.com/media/tires/ref_1.png
My script is in PHP.
New contributor
DigitalFreeMan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.