My opinion is, remove the $suffix first, and then apply splitting the core basename ( PHP 4 ):
/*
* From stephane.fidanza@gmail.com:
*
* PHP 4: $suffix is removed first, and then the core basename is applied.
* PHP 5: $suffix is removed after applying the core basename.
*
* (c) Paulus Gandung Prakosa (rvn.plvhx@gmail.com)
*/
if ( !function_exists('php4_backward_compat_basename') )
{
function php4_backward_compat_basename($path, $suffix = '')
{
if ( $suffix !== '' ) {
$fixed_path = substr($path, 0, strlen($path) - strlen($suffix));
$fixed_basename = explode('/', $fixed_path);
}
return ( isset($fixed_basename) ? array_pop($fixed_basename) : array_pop(explode('/', $path)) );
}
}