Req #64056 [Opn->Wfx]: array_rand returns differ - should always be an array
| From: | pajoye@php.net | Date: | Wed, 23 Jan 2013 15:06:31 +0000 |
| Subject: | Req #64056 [Opn->Wfx]: array_rand returns differ - should always be an array | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-176196@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=64056&edit=1
ID: 64056
Updated by: pajoye@php.net
Reported by: joern dot berkefeld at bittubes dot com
Summary: array_rand returns differ - should always be an
array
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
Package: *General Issues
Operating System: -
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
We can't change that due to backward compatibility reason.
Previous Comments:
------------------------------------------------------------------------
[2013-01-23 14:57:37] joern dot berkefeld at bittubes dot com
Description:
------------
---
From manual page: http://www.php.net/function.array-rand
---
From the manual:
"If you are picking only one entry, array_rand() returns the key for a random
entry. Otherwise, it returns an array of keys for the random entries"
That causes problems as this functionality is unexpected. Functions should always
return the same type (or false / null for failure)
Expected result:
----------------
get an array regardless of the number of results
Actual result:
--------------
the function returns an integer for one result and an array for multiple results
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64056&edit=1