Proper way to access object array

Hello forums,

How do you access object array items. I have this object stored in a string called data: Example I like to echo ‘Ford’

stdClass Object
(
    [1] => stdClass Object
        (
            [1] => 184
            [2] => 193
            [3] => 204
            [4] => 221
            [5] => Ford
            [7] => 345
            [8] => Fiesta
            [10] => 431
            [11] => 440
            [12] => 443
            [13] => 446
        )

    [2] => stdClass Object
        (
            [35] => 1396
        )

    [3] => stdClass Object
        (
            [37] => 1144
            [38] => 1147
            [39] => 1150
            [40] => 1153
            [41] => 1158
            [42] => 1160
            [44] => 1165
            [46] => 1171
        )

    [4] => stdClass Object
        (
            [50] => 501
            [54] => 512
            [57] => 18293ChasisNumber
            [63] => 23455ChasisMake
            [66] => 567
            [67] => 726
            [68] => 850
            [70] => 864
            [74] => 962
            [75] => 1037
            [79] => 1117
            [83] => 1134
        )
)

I tried
$data[0]->5 - does not work
$data->0->5 - does not work
$data[0][5] - does not work.

Any advice?
Thanks

Try this,

$data->1[5]
or
$data->1[‘5’]

Take note I think there is no index 0 in the object you posted.

Does not work. Ended up converting the object to array

$data = json_decode(json_encode($data),true);

Cheers,

I’m wondering that even though the string-to-JSON JSON-to-object works, it would likely be more efficient to look at how and why the object is being saved as a string in the first place.

Yes I agree, The string is actually dynamic product options saved on the database as a Json string. Modified json_decode to return array instead of object.