note 51566 added to function.array-shift

From: Date: Mon, 04 Apr 2005 14:24:21 +0000
Subject: note 51566 added to function.array-shift
Groups: php.notes 
Request: Send a blank email to php-notes+get-87429@lists.php.net to get a copy of this message
Be aware of the size of the array. With an array filled with 1600 lines, unshifting all the elements is much more slower than a foreach() loop !! <?php #unshift loop : 1600 lines while( $line = unshift($array) ) { //nothing to do ! } #total time : 77,3621029854 seconds ?> <?php #foreach loop : 1600 lines, the same array as above foreach( $array as $key => $line ) { unset($array[$key]); } #total time : 0,920037031174 seconds ?> ---- Manual Page -- http://www.php.net/manual/en/function.array-shift.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+51566 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51566&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51566&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51566&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51566&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51566&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+51566&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#87429) next »