green_arrow
green_arrow

Reputation: 1277

Getting file extension of unknown file name

I want to get the file extension of a file however the file name increments so I could have file_01_XX.jpg...how could I get the extension of a file where I don't know the full file name but I know the start of it?

If you could help me that would be great. Many thanks in advance.

Upvotes: 0

Views: 671

Answers (1)

Sarfraz
Sarfraz

Reputation: 382666

You can use pathinfo function like this:

$parts = pathinfo('your file name');
echo $parts['extension'];

I want to get the file extension of a file however the file name increments so I could have file_01_XX.jpg...how could I get the extension of a file where I don't know the full file name but I know the start of it?

Whatever file name it is, this will give you the extension :)

Upvotes: 1

Related Questions