如何从PHP的关联数组的内部键访问值? [英] How to access the values from inner key of associative array in PHP?

查看:158
本文介绍了如何从PHP的关联数组的内部键访问值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是可能是多维数组 $ form_data

 数组

[form_submitted] => yes
[teacher_id] => 3807f31f8c4357bbb56662047529dcde
[cs_map_ids] => Array

[0] => 144
[1] => 130
[2] => 131
[3] => 67
[4] => 89



















$ p>我只想使用foreach循环访问键 [cs_map_ids] 的值。但是无法访问数组 [cs_map_ids] 中的值。任何人都可以帮助我如何访问这些值使用foreach循环一个接一个?应该很简单,试试

<$ <$ p


解决方案

p $ p> foreach($ form_data ['cs_map_ids'] as $ map_id)
{
echo $ map_id;
}


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;
}

这篇关于如何从PHP的关联数组的内部键访问值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆