| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             [2008-04-15 23:54 UTC] scottmac@php.net
  [2008-04-16 06:34 UTC] pcdevil at freemail dot hu
  | 
    |||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 06:00:01 2025 UTC | 
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)