Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在php中从嵌套数组中获取值_Php_Arrays - Fatal编程技术网

如何在php中从嵌套数组中获取值

如何在php中从嵌套数组中获取值,php,arrays,Php,Arrays,当我通过post方法提交表单时,我得到的数组值如下所示 array 'custom_profile_type' => array 0 => string '39242' (length=5) 'satori_programme' => string '0' (length=1) 我想要上面数组中的值39242。怎么弄到的?有什么想法吗,伙计们?像..一样访问它 echo $yourarray['custom_profile_type'][0

当我通过post方法提交表单时,我得到的数组值如下所示

 array
 'custom_profile_type' => 
    array
       0 => string '39242' (length=5)
    'satori_programme' => string '0' (length=1)
我想要上面数组中的值
39242
。怎么弄到的?有什么想法吗,伙计们?

像..一样访问它

echo $yourarray['custom_profile_type'][0];

使用下面的代码访问|您可以添加循环以获得如下所示的所有值

静态代码

  echo  $array['custom_profile_type'][6]
  echo  $array['custom_profile_type'][0]
动态代码

<?php
$array = $_POST['custom_profile_type'];

foreach($array as $key => $value) {
    echo $key . " => " . $value;
}
?>

@ShankarDamodaran,是的,先生更新了。谢谢,抱歉我的错误
<?php
$array = $_POST['custom_profile_type'];

foreach($array as $key => $value) {
    echo $key . " => " . $value;
}
?>