Sometimes you just need to get the file extension from a string.  Here are a couple quick solutions to get it in literally 1 line of code.

Option #1

echo pathinfo('puppies.html', PATHINFO_EXTENSION); // Outputs: "html"

Option #2

echo substr(strrchr('puppies.html', '.'), 1); // Outputs: "html"
0 0 votes
Article Rating
in PHP tagged
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments