Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the name of the image from url?

Tags:

php

curl

I have a small question; In PHP I have used curl to get data from an URL:

$url = "http://www.prelovac.com/vladimir/wp-content/uploads/2008/03/example.jpg";

With that I use curl_getinfo() which gave me an array:

Array
(
[url] => http://www.prelovac.com/vladimir/wp-content/uploads/2008/03/example.jpg
[content_type] => image/jpeg
[http_code] => 200
[header_size] => 496
[request_size] => 300
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 2.735
[namelookup_time] => 0.063
[connect_time] => 0.063
[pretransfer_time] => 0.063
[size_upload] => 0
[size_download] => 34739
[speed_download] => 12701
[speed_upload] => 0
[download_content_length] => 34739
[upload_content_length] => -1
[starttransfer_time] => 1.282
[redirect_time] => 0
)

How can I get the name of the image in the link [url] => http://www.prelovac.com/vladimir/wp-content/uploads/2008/03/example.jpg such as

[image_name] : example
[image_ex] : jpg

Thanks for any suggestion!

like image 358
johnITBonuc Avatar asked Dec 19 '11 04:12

johnITBonuc


1 Answers

Use pathinfo

like image 97
Markel Mairs Avatar answered Oct 24 '22 16:10

Markel Mairs