From:             pcdevil at freemail dot hu
Operating system: ubuntu linux
PHP version:      5.2.5
PHP Bug Type:     Arrays related
Bug description:  array_rand doesn't return object

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 bug report at http://bugs.php.net/?id=44737&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=44737&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=44737&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=44737&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=44737&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=44737&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=44737&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=44737&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=44737&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=44737&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=44737&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=44737&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=44737&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=44737&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=44737&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=44737&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=44737&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=44737&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=44737&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=44737&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=44737&r=mysqlcfg

Reply via email to