note 70866 deleted from ref.array by felipe

From: Date: Sun, 30 Dec 2007 19:27:05 +0000
Subject: note 70866 deleted from ref.array by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-134516@lists.php.net to get a copy of this message
Note Submitter: zspencer at zacharyspencer dot com ---- The array system is sadly lacking a "set" function... I needed one that would set the pointer to the key that I specified. So I wrote my own. <? $array=array(); $array['a']='lala'; $array['b']='blabla'; $array['c']='nono'; set($array, 'b'); echo current($array); // outputs blabla function set(&$array, $key) { reset($array); while($current=key($array)) { if($current==$key) { return true; } next($array); } return false; } ?>

« previous php.notes (#134516) next »