HostOnNet Blog

PHP function to find file extension

Looking for Linux Server Admin or WordPress Expert? We can help.

To find file extension with PHP, use pathinfo function

<?php

$video = 'hostonnet.avi';
$info = pathinfo($video);
echo '<pre>';
print_r($info);

// File extension

echo $info['extension'] . "<br>"; // avi

// File Name with out extension

echo $info['filename'] . "<br>"; // hostonnet


Posted in PHP

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.