0

I'm new to PHP and WordPress, and i need to import image from a offshore website with the WordPress function download_URL().

My problem is, i have URL that look like that :

http://www.test/img/FMR.jpg

But i have also URL that look like that :

http://www.test/img/FMR.jpg?Qq_0y12h

And can i have remove everything that is after the .extension if there something?

Gustav
  • 79
  • 2
  • 12

1 Answers1

0

you can use preg_replace, I did this little example for you.

<?php
$url = "http://www.test/img/FMR.jpg?Qq_0y12h";

echo "url = $url\n\n";

$urlFormatted = preg_replace("/\?.*$/", "", $url);
echo "urlFormatted = $urlFormatted\n";

?>