7.2.1、二维数组的创建

 
 PHP Code By tony
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php

    $products = array(
                
array('苹果',6,28.2),
                
array('猪肉',3,36.3),
                
array('饼干',3,28.3)
            );
    
    print_r($products);
    
    
// 打印第一个数组中的元素
    echo $products[0][0];
    
echo $products[0][1];
    
echo $products[0][2];
    
    
echo '<br>';
    
echo '循环打印数组<br>';
    
    
// 循环打印
    for ($i=0;$i<count($products);$i++){
        
for ($j=0;$j<count($products[$i]);$j++){
            
echo $products[$i][$j].'<br>';
        }
    }
    
?>




原文地址:https://www.cnblogs.com/tonycody/p/2795372.html