note 73038 deleted from function.array-keys by danbrown

From: Date: Wed, 25 Aug 2010 01:48:19 +0000
Subject: note 73038 deleted from function.array-keys by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-172007@lists.php.net to get a copy of this message
Note Submitter: jason at ajax dot hk ---- just tested the following example on offical help, and found that the way array_keys() works have been changed (it now correctly return all keys even through some values are identical) <? $array = array("blue", "red", "green", "blue", "blue"); print_r(array_keys($array, "blue")); ?> ----------------output start------------------- Array ( [0] => 0 [1] => 3 [2] => 4 ) -----------------output end-------------------- here's my code: [code] <? $array = array("blue", "red", "green", "blue", "blue","blue", "blue"); echo '<br />source array<br />'; print_r($array); echo '<br /><br />result of array_keys() <br />'; print_r(array_keys($array)); ?> [/code] ----------------output start------------------- source array Array ( [0] => blue [1] => red [2] => green [3] => blue [4] => blue [5] => blue [6] => blue ) result of array_keys() Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 [6] => 6 ) -----------------output end--------------------

« previous php.notes (#172007) next »