php从多维数组中提取

时间:2013-11-16 13:48:56

标签: php multidimensional-array

我有如下的多维数组,从print_r($mArray);调用。如何打印输出,如下面的示例?

Array ( [0] => Array ( [pamount] => Array ( [0] => 190 [1] => 190 ) [psubject] => Array ( [0] => A [1] => A ) [ptype] => Array ( [0] => Water [1] => Internet ) ) ) 

样品

Subject | Type    |Amount
A       | Water   |109
A       | Internet|109

1 个答案:

答案 0 :(得分:1)

试试这个:

$index = 0;
foreach($array['pamount'] as $key => $value){
   echo '<span>'.$value.'</span>
         <span>'.$array['psubject'][$index].'</span>
         <span>'.$array['ptype'][$index].'</span><br>';
   $index++;
}
相关问题