3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function canonicalize($address) { $address = explode('/', $address); $keys = array_keys($address, '..'); foreach($keys AS $keypos => $key) { array_splice($address, $key - ($keypos * 2 + 1), 2); } $address = implode('/', $address); $address = str_replace('./', '', $address); return $address; } echo canonicalize("http://www.zakzak.co.jp/entertainment/ent-news/news/20140216//../../../../entertainment/ent-news/images/20140216/enn1402161257010-n1.jpg");
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
http://www.zakzak.co.jp/entertainment/entertainment/ent-news/images/20140216/enn1402161257010-n1.jpg