note 71769 added to ref.array

From: Date: Thu, 14 Dec 2006 23:11:53 +0000
Subject: note 71769 added to ref.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-120619@lists.php.net to get a copy of this message
I just realised that my function did not work, with an array filled with booleans : next($tab) can return false even if it is not the last... This one works ... unless false is one of your keys. In this case I suggest using a counter and sizeof($tab) as a condition for exiting the loop : <? function set(&$tab, $key){ reset($tab); while ( ($key != key($tab)) && key($tab) ){next($tab);} return current($tab); } ?> ---- Server IP: 66.163.161.117 Probable Submitter: 83.156.66.20 ---- Manual Page -- http://www.php.net/manual/en/ref.array.php Edit -- https://master.php.net/note/edit/71769 Del: integrated -- https://master.php.net/note/delete/71769/integrated Del: useless -- https://master.php.net/note/delete/71769/useless Del: bad code -- https://master.php.net/note/delete/71769/bad+code Del: spam -- https://master.php.net/note/delete/71769/spam Del: non-english -- https://master.php.net/note/delete/71769/non-english Del: in docs -- https://master.php.net/note/delete/71769/in+docs Del: other reasons-- https://master.php.net/note/delete/71769 Reject -- https://master.php.net/note/reject/71769 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#120619) next »