Getting a file extension using PHP

<?php
function getExt($filename){
		return substr(strrchr($filename, '.'), 1);
	}

$file = 'myphoto.jpg';

echo getExt($file);

?>

The output is

function getExt($filename){
return substr(strrchr($filename, '.'), 1);
}

$file = 'myphoto.jpg';
echo '

‘;
echo getExt($file);
echo ‘

‘;
?>

PG

Author: insic

Subscribe in my RSS Feed for more updates on Web Design and Development related articles. Follow me on twitter or drop a message to my inbox.

Related Post

Delicious

No comments yet... Be the first to leave a reply!

Leave a Reply