3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $scandir = "home:///Pierpaolo/file.txt"; $scandir = preg_replace("/\/$/", "", $scandir); $scandir = preg_replace("/\/\.\.\/?/", "/", $scandir); $scandir = preg_replace("/\/$/", "", $scandir); echo $scandir; if ( (preg_match("/^([A-z0-9\-_]+)?\:\/\/?(.*)/", $scandir, $matches)) !== false ) { if ( sizeof($matches) === 3 ) { $protocol = "{$matches[1]}://"; $dirname = $matches[2]; } } echo $protocol." - ".$dirname ;
based on rJVAn
Output for 5.3.20 - 7.2.0
home:///Pierpaolo/file.txthome:// - /Pierpaolo/file.txt