PHP : What is the better way to access object inside an array then what i got now ?

Posted by justjoe on Stack Overflow See other posts from Stack Overflow or by justjoe
Published on 2010-03-30T05:10:21Z Indexed on 2010/03/30 5:13 UTC
Read the original article Hit count: 530

Filed under:
|
|

$jj_post is the array output debug via print_r. this variable is an array of object

Array
(
    [0] => stdClass Object
        (
            [ID] => 2571
        )

)

i access the object property, ID, via code like this :

$jj_post_id = $jj_post[0]; 
$jj_ID = $jj_post_id->ID;

so, is there a better way, cause this is the only thing i know and i feel the code little bit too long ?

© Stack Overflow or respective owner

Related posts about php

Related posts about arrays