note 36397 added to ref.array

From: Date: Wed, 08 Oct 2003 15:45:56 +0000
Subject: note 36397 added to ref.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-58055@lists.php.net to get a copy of this message
This is the optimization function (thanks to the guy that posted it on 12-Feb-2003) for removing empty values of an array that I've rewritten to gain speed. It's twice faster if we just use it like this: function arryOpt(&$array) // pass by reference { if(!is_array($array)) return false; $temp=array(); foreach($array as $v) { if(!empty($v)) $temp[]=$v; } $array=$temp; return true; } Moreover, (contrary to what I believed) the version of passing it by value behaves even (a litle) faster. function arryOpt($array) // pass by value { if(!is_array($array)) return false; $temp=array(); foreach($array as $v) { if(!empty($v)) $temp[]=$v; } $array=$temp; return $array; } ---- Manual Page -- http://www.php.net/manual/en/ref.array.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+36397 Delete -- http://master.php.net/manage/user-notes.php?action=delete+36397&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+36397&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#58055) next »