How can i print Multidimensional Arrays in php [duplicate]

陌路散爱 提交于 2021-02-08 12:15:34

问题


Array       
(       
    [0] => Array        
        (       
            [0] => HUBZone Small Business       
            [1] => Small Disadvantaged Business     
            [2] => Service-Disabled Veteran Small Businesses        
        )       
)

回答1:


$array ;

foreach($array as $key => $value){
   foreach($value as $k => $val){
      echo $val . "<br> ;
   }
}

Output:

HUBZone Small Business  
Small Disadvantaged Business
Service-Disabled Veteran Small Businesses 



回答2:


print_r($array);

If given a string, integer or float, the value itself will be printed. If given an array, values will be presented in a format that shows keys and elements. Similar notation is used for objects.

For more info: php.net/print_r




回答3:


use foreach loops.

For your above array:

   foreach($arr as $a){
       foreach($a as $k=>$v){
           echo $v;
       }
    }


来源:https://stackoverflow.com/questions/22681206/how-can-i-print-multidimensional-arrays-in-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!