note 64335 deleted from function.key by googleguy

From: Date: Tue, 22 Oct 2013 06:53:45 +0000
Subject: note 64335 deleted from function.key by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-196697@lists.php.net to get a copy of this message
Note Submitter: danny at dannymendel dot com ---- An auto incremental key value function, returning the key value: <? function add_key ($value, $array) // returns the key of the value added or existing already within the array { if (is_array ($array)) { if (!in_array ($value, $array)) { ksort ($array); end ($array); $key = key ($array) + 1; $array[$key] = $value; } else { $key = array_search ($value, $array); } } else { $key = 1; $array[$key] = $value; } return $key; } ?>

« previous php.notes (#196697) next »