note 86783 added to function.array-shift

From: Date: Mon, 03 Nov 2008 20:50:27 +0000
Subject: note 86783 added to function.array-shift
Groups: php.notes 
Request: Send a blank email to php-notes+get-146095@lists.php.net to get a copy of this message
Using array_shift over larger array was fairly slow. It sped up as the array shrank, most likely as it has to reindex a smaller data set. For my purpose, I used array_reverse, then array_pop, which doesn't need to reindex the array and will preserve keys if you want it to (didn't matter in my case). Using direct index references, i.e., array_test[$i], was fast, but direct index referencing + unset for destructive operations was about the same speed as array_reverse and array_pop. It also requires sequential numeric keys. ---- Server IP: 209.41.74.194 Probable Submitter: 209.114.137.18 ---- Manual Page -- http://www.php.net/manual/en/function.array-shift.php Edit -- https://master.php.net/note/edit/86783 Del: integrated -- https://master.php.net/note/delete/86783/integrated Del: useless -- https://master.php.net/note/delete/86783/useless Del: bad code -- https://master.php.net/note/delete/86783/bad+code Del: spam -- https://master.php.net/note/delete/86783/spam Del: non-english -- https://master.php.net/note/delete/86783/non-english Del: in docs -- https://master.php.net/note/delete/86783/in+docs Del: other reasons-- https://master.php.net/note/delete/86783 Reject -- https://master.php.net/note/reject/86783 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#146095) next »