如何从多维数组中获取值

时间:2015-09-24 12:02:06

标签: multidimensional-array

  

数组([0] =>数组([数据] =>数组([0] =>数组([like_info] =>数组([like_count] => 30)[comment_info] =&gt ;数组([comment_count] => 6)[share_count] => 17 [attachment] =>数组([description] => Mitkkk kkssk [media] =>数组([0] =>数组( [src] => com.jpg& cfs = 1))[name] => euch)[permalink] => example.com/47457343655 [created_time] => 1925))))

如何从此处列出的变量中的所有列中获取值

  • LIKE_COUNT
  • SHARE_COUNT
  • COMMENT_COUNT
  • 描述
  • src
  • 永久链接
  • CREATED_TIME

1 个答案:

答案 0 :(得分:0)

你可以创建一个变量向量,我的意思是一个数组:

$var = array();

然后你可以做一个双循环来获取多维数组的所有值并将它们存储在向量上,如:

for($i = 0; i< count($yourarray); i++){
   if(is_array($yourarray[i])){
      for($j = 0; j< count($yourarray[i]); j++) $var[] = $yourarray[i][j];

   }else $var[] = $yourarray[i];
}