Reputation: 3536
I am using File
class for getting extention of image url.
File::extension($image_path)
But my image URL is example.com/images/new.png?v=21212154
It returns png?v=21212154
How to get the value png
only?
Upvotes: 0
Views: 931
Reputation: 93
Try to use pathinfo():
$extension = pathinfo($image_path, PATHINFO_EXTENSION);
or
$info = pathinfo(image_path);
$extension = $info['extension'];
Upvotes: 0
Reputation: 21681
You should try this way:
$url = 'example.com/images/new.png?v=21212154';
$data = explode('?',$test);
$data = explode('/',$data[0]);
$filename = $data[2];
$extention = File::extension($filename);
OR Try with below code.
$result = File::extension($image_path)
$url = strstr($result,"?");
echo str_replace($url,"",$result);
Upvotes: 1