Jump to content

can not retrieve values from 3 dimensional array with foreach


saiyen2002

Recommended Posts

I am trying to iterate through a 3 dimensional array and echo out all the details. I am having a trouble with the following:

 

Array
(
    [DT_Intrinsic_mob7] => Array
        (
            [0] => Array
                (
                    [cli] => 11111111111
                    [min] => 533
                )

            [1] => Array
                (
                    [cli] => 2222222222
                    [min] => 536
                )

            [2] => Array
                (
                    [cli] => 33333333333
                    [min] => 541
                )

------- SNIP -----
           [46] => Array
               (
                    [cli] => 5555555555
                    [min] => 5471
                )

        )

    [DT_belltel_mob7] => Array
        (
            [0] => Array
                (
                    [cli] => 999999999
                    [min] => 508
                )

            [1] => Array
                (
                    [cli] => 8888888888
                    [min] => 519
                )

            [2] => Array
                (
                    [cli] => 7777777777
                    [min] => 602
                )

            [3] => Array
                (
                    [cli] => 7975757375
                    [min] => 701
                )


        )

)


 

My code looks like this:

 

foreach ($cli_data as $key => $value){
        foreach ($cli_data[$key] as $key2 => $value2){
                foreach($cli_data[$key][$key2] as $key3 => $value3){
                        echo "key3 is $key3 \n";
                        echo "value is $value3['cli']";
                }
        }
        echo "\n\n";
}

 

I keep getting the following error

 

PHP Parse error:  syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/www/html/index.php on line

 

Thanks

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.