note 81935 modified in function.realpath by danbrown

From: Date: Mon, 01 Jun 2009 12:58:50 +0000
Subject: note 81935 modified in function.realpath by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-156225@lists.php.net to get a copy of this message
<?php //rp like, working with absolute/relative path & a little bit shorter :p function rp($path) { $out=array(); foreach(explode('/', $path) as $i=>$fold){ if ($fold=='' || $fold=='.') continue; if ($fold=='..' && $i>0 && end($out)!='..') array_pop($out); else $out[]= $fold; } return ($path{0}=='/'?'/':'').join('/', $out); } ?> --was-- <? //rp like, working with absolute/relative path & a little bit shorter :p function rp($path) { $out=array(); foreach(explode('/', $path) as $i=>$fold){ if ($fold=='' || $fold=='.') continue; if ($fold=='..' && $i>0 && end($out)!='..') array_pop($out); else $out[]= $fold; } return ($path{0}=='/'?'/':'').join('/', $out); } http://php.net/manual/en/function.realpath.php

« previous php.notes (#156225) next »