Get values from Array and use in function

Hi im printing my array at following method

echo '<pre>';
print_r($auto);
echo '</pre>';

I get my information in array as follow

stdClass Object
(
    [messages] => 
    [status] => 1
    [metadata] => stdClass Object
        (
        )

    [data] => stdClass Object
        (
            [testdomain.no] => stdClass Object
                (
                    [keys] => stdClass Object
                        (
                            [28131] => stdClass Object
                                (
                                    [active] => 1
                                    [algo_num] => 8
                                    [flags] => 256
                                    [key_id] => 2
                                    [algo_tag] => RSASHA256
                                    [key_type] => ZSK
                                    [bits] => 1024
                                    [key_tag] => 28131
                                    [algo_desc] => RSA/SHA-256
                                )

                            [65407] => stdClass Object
                                (
                                    [flags] => 257
                                    [algo_num] => 8
                                    [digests] => Array
                                        (
                                            [0] => stdClass Object
                                                (
                                                    [algo_desc] => SHA-1
                                                    [digest] => dbec59d734de29afc40200e92e7936f8b871a50c
                                                    [algo_num] => 1
                                                )

                                            [1] => stdClass Object
                                                (
                                                    [algo_desc] => SHA-256
                                                    [digest] => 1b93ea410575d6569217d6508a52fee5a460d6c11381db58cf3bbe45b4c06823
                                                    [algo_num] => 2
                                                )

                                            [2] => stdClass Object
                                                (
                                                    [digest] => b974fdd98db70739820ae8f48079234a66bd20797c872f6457b5fd8091867457c4b53ebc77f1f7da45448ec77d9e8f2a
                                                    [algo_num] => 4
                                                    [algo_desc] => SHA-384
                                                )

                                        )

I had hoped that i could use the values as follow in my function further on in my function but this doesnt work. Please advice…

$auto[digests]['0'][algo_desc];
$auto[digests]['0'][digests];
$auto[digests]['0'][algo_num];

$auto[digests]['1'][algo_desc];
$auto[digests]['1'][digests];
$auto[digests]['1'][algo_num];

first… try without quotes in your index #'s

$auto[digests][1][algo_desc];

not

$auto[digests][‘1’][algo_desc];

@whispers, that isn’t going to work.

No you dont. you have an object. You need to access it as an object or convert it to an array.

Ok, and how do I do this?

How do you access the object as an array?

$obj = json_decode(json_encode($auto), true);
print_r($obj);
Sponsor our Newsletter | Privacy Policy | Terms of Service