2017-05-09 52 views

回答

0

如果你正在做JavaScript,可以這樣做,如果你知道什麼密鑰來調用你的數據。

var arr = ([ 
 
    ["name","e-mail","contact","address"], 
 
    ["santosh","[email protected]","9035619733","hennur"], 
 
    ["santosh2","[email protected]","90356197332","hennur2"], 
 
    ["santosh3","[email protected]","90356197333","hennur3"] 
 
]); 
 

 
console.log(arr[1][1]);

0

您的數據:

$data = [[ 

      'name', 
      'email', 
      'contact', 
      'address' 
     ], 
     [ 
      'santosh', 
      '[email protected]', 
      '9035619733', 
      'hennur' 
     ] 
     ]; 

PHP代碼:

$title = $data[0]; 
     unset($data[0]); 
     $table = '<table border="1">'; 
     $table .='<tr>'; 
     foreach($title as $k=>$val){ 
     $table.='<td>'.$val.'</td>'; 
     }; 
     $table.='<tr/>'; 
     foreach($data as $key=>$val){ 
     $table.='<tr>'; 
     foreach($title as $k=>$v){ 
      $table.='<td>'.$val[$k].'</td>'; 
     } 
     $table.='</tr>'; 

     } 
     $table.='</table>'; 
     echo $table; 

輸出:

name email     contact  address 
santosh [email protected] 9035619733 hennur 
相關問題