Reputation: 6903
Let say I have image.jpg on my directory.
And assume that the only detail I know is that I have a filename which name = 'image' but i don't know what it's extension.
Is there a PHP function to know the extension of the file?
Upvotes: 0
Views: 593
Reputation: 224913
You can find the files with glob
:
$matching = glob('/some/directory/' . $name . '.*');
Upvotes: 3
Reputation: 578
http://php.net/manual/en/function.pathinfo.php shows everything you need, path, filename and extension.
Upvotes: 0