3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function getExt($filename) { if(!is_file($filename)) return ''; $n = strlen($filename); if($n<2) return ''; $non_ext = ''; $ext = ''; Echo $filename; for($i=$n;$i--;$i>=1) { $c = $filename[$i]; if($c==='.') { $ext = '.'.$non_ext.$ext; $non_ext = ''; }else $non_ext = $c.$non_ext; } return $ext; } $filename = "asdfasdfasd.tar.gz"; $ext = getExt($filename); var_dump($ext);
based on 2N3X2
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.2.0
string(0) ""