3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $path = '/a/b/c/d/e.f'; $matches = preg_split('/\/|\\\/', $path); $filename = $matches[count($matches) - 1]; $path = implode(DIRECTORY_SEPARATOR, $matches); if(strpos($filename, '.') !== -1) { $ext = substr($filename, strpos($filename, '.')); echo $ext; }
Output for 4.3.0 - 7.1.0
.f