// Everything you enter here will be executed by our servers. Try it!
$str = "safsad fd sm. pfle.jpg";
echo $a = strrpos($str,".");
$str2 = substr($str,0,$a);
$str3 = preg_replace("/[-, :;]/","_",$str2);