$filePath = 'images\photo_img\SK2-50 Black.JPG';
$filePath = preg_replace('/^images\\\\photo_img\\\\([^\.]*)\.\w{3}$/', '$1', $filePath);
echo $filePath;
使用上面的正则表达式替换即可
$filePath = "images\photo_img\SK2-50 Black.JPG";
$filename = basename($filePath);
$arr = explode('.', $filename);
echo "";";
print_r($arr);
echo $arr[0];
echo "
exit;