1 2 3 4 5 6 7
<?php $path = '/somewhere/somefile.jpg'; $withoutExt = preg_replace('/\.' . preg_quote(pathinfo($path, PATHINFO_EXTENSION), '/') . '$/', '', $path); echo $withoutExt;
1
/somewhere/somefile