2013-03-19 59 views
4
$list=array('Andaman and Nicobar'=>array('North and Middle Andaman', 'South Andaman', 'Nicobar'), 'Andhra Pradesh' => array('Adilabad', 'Anantapur',)); 

如何打印多维数组?

[['North and Middle Andaman', 'South Andaman', 'Nicobar'],['Adilabad', 'Anantapur']] 
+0

所以你问如何让PHP输出该嵌套数组的JSON表示?为什么JavaScript标签? – nnnnnn 2013-03-19 05:43:24

回答

6
$tmp = json_encode($list); 
echo $tmp; 
0

形式可以通过PHP 这里一个简单的例子打印多维数组...

<?php 
    $company = array(
     array('company','HCL', 'Microsoft','apple'), 
     array('city ','Delhi','California','Newyork'), 
     array('Type','IT','Software','Iphone') 
    ); 
    ?> 
    <table border="1"> 

    <?php 
    foreach($company as $data) 
    { 
     echo '<tr>'; 
     foreach($data as $item) 
     { 
      echo "<td>$item</td>"; 


     } 
     echo '</tr>'; 
    } 
?> 

不要说感谢名单给我... :) )