ID:               44737
 Updated by:       [EMAIL PROTECTED]
 Reported By:      pcdevil at freemail dot hu
-Status:           Open
+Status:           Bogus
 Bug Type:         Arrays related
 Operating System: ubuntu linux
 PHP Version:      5.2.5
 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

array_rand returns a key, so its picking a key randomly from $array.


Previous Comments:
------------------------------------------------------------------------

[2008-04-15 23:34:50] pcdevil at freemail dot hu

Description:
------------
if i use array_rand in an array with object values, it return only an
integer (key?) value.

Reproduce code:
---------------
<?php
class SimpleClass {
        public $integer=0;
        
        function __construct($i) {
                $this->integer=$i;
        }
}

$array=array();
for ($i=0;$i<10;++$i)
        $array[]=new SimpleClass($i);

var_dump(array_rand($array));

?>

Expected result:
----------------
//like that:

object(SimpleClass)#125 (1) {
  ["integer"]=>
  int(3)
}


Actual result:
--------------
//like that:

int(2)


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=44737&edit=1

Reply via email to