3v4l.org

run code in 200+ php & hhvm versions
<?php $string = 'var/log/some/other/directory/file.log'; $array = explode('/', $string); for ($c = count($array); $c > 0; ) { $output[--$c] = implode('/', $array); array_pop($array); } for ($i = 0; $i < count($output); $i++) { echo "$output[$i]\n"; }
Output for 7.1.25 - 7.3.1
var var/log var/log/some var/log/some/other var/log/some/other/directory var/log/some/other/directory/file.log