Sam San
Sam San

Reputation: 6903

PHP find file extension of match filename

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

Answers (2)

Ry-
Ry-

Reputation: 224913

You can find the files with glob:

$matching = glob('/some/directory/' . $name . '.*');

Upvotes: 3

Skynet
Skynet

Reputation: 578

http://php.net/manual/en/function.pathinfo.php shows everything you need, path, filename and extension.

Upvotes: 0

Related Questions