PHP Get extension with explode

Get extension with explode

<?
$file = "test.txt";
$part = explode(".",$file);
$ext = $part[count($part)-1];
?>