很遺憾,經過 20 年的發展,我們竟然還沒有 mb_basename() 函數!
// 適用於 Windows 和 Unix 系統
function mb_basename($path) {
if (preg_match('@^.*[\\\\/]([^\\\\/]+)$@s', $path, $matches)) {
return $matches[1];
} else if (preg_match('@^([^\\\\/]+)$@s', $path, $matches)) {
return $matches[1];
}
return '';
}