cvs: pear /File/File Util.php

From: Date: Wed, 02 Mar 2005 14:25:41 +0000
Subject: cvs: pear /File/File Util.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-29991@lists.php.net to get a copy of this message
mike Wed Mar 2 09:25:41 2005 EDT Modified files: /pear/File/File Util.php Log: * rather use foreach(array_keys()) than for(count()) in buildPath() http://cvs.php.net/diff.php/pear/File/File/Util.php?r1=1.16&r2=1.17&ty=u Index: pear/File/File/Util.php diff -u pear/File/File/Util.php:1.16 pear/File/File/Util.php:1.17 --- pear/File/File/Util.php:1.16 Wed Feb 23 11:43:00 2005 +++ pear/File/File/Util.php Wed Mar 2 09:25:40 2005 @@ -11,7 +11,7 @@ // | Copyright (c) 2005 Michael Wallner <mike@iworks.at> | // +----------------------------------------------------------------------+ // -// $Id: Util.php,v 1.16 2005/02/23 16:43:00 mike Exp $ +// $Id: Util.php,v 1.17 2005/03/02 14:25:40 mike Exp $ /**#@+ * Sorting Constants @@ -57,13 +57,9 @@ */ function buildPath($parts, $separator = DIRECTORY_SEPARATOR) { - /* - * @FIXXME: maybe better use foreach - */ - - for ($i = 0, $c = count($parts); $i < $c; $i++) { - if ( !strlen($parts[$i]) || - preg_match('/^'. preg_quote($separator, '/') .'+$/', $parts[$i])) { + $qs = '/^'. preg_quote($separator, '/') .'+$/'; + foreach (array_keys($parts) as $i) { + if (!strlen($parts[$i]) || preg_match($qs, $parts[$i])) { unset($parts[$i]); } elseif (0 == $i) { $parts[$i] = rtrim($parts[$i], $separator);

« previous php.pear.cvs (#29991) next »