Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
348 views
in Technique[技术] by (71.8m points)

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

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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Use pathinfo


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...