PHP Explode, PHP End, File Name, File Extension
if ( ! function_exists(‘file_parts’))
{
function file_parts($url,$params=’ext’)
{
if($params==’ext’)
{
$parts = explode(‘.’,$url);
return end($parts);
}
elseif($params==’name’)
{
$parts = explode(‘/’,$url);
return end($parts);
}
else
{
$parts = explode(‘/’,$url);
$file_name_ext = explode(‘.’,end($parts));
$file_name = array_pop($file_name_ext);
return implode(‘.’,$file_name);
}
}
}
Last updated: March 19, 2014