【问题标题】:how to print mulidimensional array? [closed]如何打印多维数组? [关闭]
【发布时间】:2013-03-19 05:35:41
【问题描述】:
$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']]

【问题讨论】:

  • 那么您是在问如何让 PHP 输出该嵌套数组的 JSON 表示?为什么是 JavaScript 标签?

标签: php javascript json


【解决方案1】:
$tmp = json_encode($list);
echo $tmp;

【讨论】:

    【解决方案2】:

    可以通过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>';
        }
    ?>
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-09-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多