note 73038 added to function.array-keys

From: Date: Wed, 07 Feb 2007 05:30:53 +0000
Subject: note 73038 added to function.array-keys
Groups: php.notes 
Request: Send a blank email to php-notes+get-123029@lists.php.net to get a copy of this message
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-------------------- ---- Server IP: 58.65.236.81 Probable Submitter: 203.198.3.64 ---- Manual Page -- http://www.php.net/manual/en/function.array-keys.php Edit -- https://master.php.net/note/edit/73038 Del: integrated -- https://master.php.net/note/delete/73038/integrated Del: useless -- https://master.php.net/note/delete/73038/useless Del: bad code -- https://master.php.net/note/delete/73038/bad+code Del: spam -- https://master.php.net/note/delete/73038/spam Del: non-english -- https://master.php.net/note/delete/73038/non-english Del: in docs -- https://master.php.net/note/delete/73038/in+docs Del: other reasons-- https://master.php.net/note/delete/73038 Reject -- https://master.php.net/note/reject/73038 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#123029) next »