note 93367 rejected from language.types.object by danbrown
| From: | danbrown@php.net | Date: | Sun, 06 Sep 2009 18:53:59 +0000 |
| Subject: | note 93367 rejected from language.types.object by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-160260@lists.php.net to get a copy of this message | ||
Note Submitter: heresy dot mc at gmail dot com
----
Now,I run into a problem: when I turn an array to an object, the items in array with number index
are not access through object's operator syntax.
See bellow:
<?php
$myarr = array(
'persion',
'name' => 'spring',
'age' => 26
...
);
$myobj = (object) $myarr;
/*
bellow will print all properties of $myobj:
stdClass Object
(
[0] => person
[name] => spring
[age] => 26
...
)
*/
print_r($myobj);
echo $myobj->{0}; // this connot work!!!
Who else can help? Thanks for all!!!