#32656 [Opn->Bgs]: array_rand does not return array
| From: | sniper@php.net | Date: | Sun, 10 Apr 2005 18:29:29 +0000 |
| Subject: | #32656 [Opn->Bgs]: array_rand does not return array | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-76597@lists.php.net to get a copy of this message | ||
ID: 32656
Updated by: sniper@php.net
Reported By: yagi at thinkware dot jp
-Status: Open
+Status: Bogus
Bug Type: *General Issues
Operating System: any
PHP Version: 4.3.11
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Previous Comments:
------------------------------------------------------------------------
[2005-04-10 17:21:17] yagi at thinkware dot jp
Description:
------------
array_rand doesn't return array but a key as string when
given mixed array which has only one value(and key).
Reproduce code:
---------------
$array = array("test");
$rand_key = array_rand($array, count($array));
print_r($rand_key);
print("\n");
$array2 = array("test" => "value");
$rand_key2 = array_rand($array2, count($array2));
print_r($rand_key2);
print("\n");
$array3 = array("test" => "value", "test2" =>
"value2");
$rand_key3 = array_rand($array3, count($array3));
print_r($rand_key3);
print("\n");
Expected result:
----------------
Array([0] => 0)
Array([0] => test)
Array
(
[0] => test
[1] => test2
)
*the last one is right. Above two are not expected
result.
Actual result:
--------------
0
test
Array
(
[0] => test
[1] => test2
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=32656&edit=1