如何打印多维数组?

时间:2013-03-19 05:35:42

标签: php javascript json

$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']]

2 个答案:

答案 0 :(得分:6)

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

答案 1 :(得分: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>';
    }
?>

不要对我说... ... :))