PHP基础16:多维数组

<?php

    //1.PHP-两维数组
    $cars=array
    (
        array("Volvo",22,18),
        array("BMW",15,13),
        array("Saab",5,2),
        array("Land Rover",17,15)
    );
    echo $cars[0][0].":库存:".$cars[0][1].":已售:".$cars[0][2];
    echo "<br>";
    echo $cars[1][0].":库存:".$cars[1][1].":已售:".$cars[1][2];
    echo "<br>";
    echo $cars[2][0].":库存:".$cars[2][1].":已售:".$cars[3][2];
    echo "<hr>";

    echo "<table border='1' cellpadding='10' style='border-collapse: collapse;'>";
    echo "<tr>";
    echo "<td>品牌</td>";
    echo "<td>库存</td>";
    echo "<td>已售</td>";
    echo "</tr>";
    for ($row=0; $row < 4; $row++) {
        echo "<tr>";
        for ($col=0; $col < 3; $col++) {
            echo "<td>";
            echo $cars[$row][$col];
            echo "</td>";
        }
        echo "</tr>";
    }
    echo "</table>";
?>
上一篇:(转)Spring Boot(八):RabbitMQ 详解


下一篇:hihocoder 1305 - 区间求差 - [hiho一下152周][区间问题]