简体   繁体   中英

How to access the values from inner key of associative array in PHP?

Following is may multidimensional array named $form_data :

Array
(
    [form_submitted] => yes
    [teacher_id] => 3807f31f8c4357bbb56662047529dcde
    [cs_map_ids] => Array
        (
            [0] => 144
            [1] => 130
            [2] => 131
            [3] => 67
            [4] => 89
        )

    [btn_submit] => Done
)

I want to access only the values from key [cs_map_ids] using foreach loop. But couldn't access the values inside array [cs_map_ids] . Can anyone help me out on how should I access these values one by one using foreach loop? Thanks in Advance.

Should be quite straight forward, try

foreach($form_data['cs_map_ids'] as $map_id)
{
    echo $map_id;
}
foreach ($form_data['cs_map_ids'] as $d) echo "$d<br />";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM