$filename="ciao.mamma.jpg";
$boom=explode(".",$filename);
$last=count($boom)-1;
$ext=$boom[$last];