My code
<?php
$video_thumb_large = 'some.example-file.name.png'; /** define a file name here **/
/** The line below is giving me what I need **/
$video_thumb_extension_large = substr($video_thumb_large, strrpos($video_thumb_large, '.') + 1);
echo $video_thumb_extension_large; /** Output: png **/
?>
There are other methods to get the file extension, for example this Stack Overflow question has some answers but my code was not available in the answers.
I'm wondering why my code is good or bad and why or why not to use my code on a production site. What is better to do in this case? I can also use explode()
on the dot and use the last part in the array()
but is it better?
What would be better or the best to get the file extension without the dot (.)?