I suggest that you use kitchin's suggestion of [man]pathinfo/man with [man]basename/man since it both deals with the case of multiple periods in the filename, and with the case where your initial filename has a directory path prepended.
Still, if you want to do what execute's code does, you should use:
if (($period_pos = strrpos($init_filename, '.')) !== false) {
$filename = substr($init_filename, 0, $period_pos);
$extension = substr($init_filename, $period_pos + 1);
} else {
$filename = $init_filename;
$extension = '';
}
or
$filename = explode('.', $init_filename);
$extension = (count($filename) > 1) ? array_pop($filename) : '';
$filename = implode('.', $filename);
where $init_filename is the original filename that you want to parse.