Blogger Information
Blog 5
fans 0
comment 0
visits 2831
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
11.13 arrays and loops
肖申克
Original
480 people have browsed it

实例

<?php
$arr1 = array(0, 'one', 2.2, true, null);
$arr2 = [0, 'one', 2.2, true, null];

$arr3 = [
    [
        'name' => 'jason',
        'number'=>1111,
        'age' => 15,
        'hobbies'=> [
            'badminton',
            'skiing',
            'cooking'
        ]
    ],
    [
        'name'=>'james',
        'number'=>2222,
        'age'=>16,
        'hobbies'=>[
            'music',
            'tennis',
            'biking'
        ]
    ],
    [
        'name'=>'jack',
        'number'=>3333,
        'age'=>17,
        'hobbies'=>[
            'swimming',
            'reading',
            'coding'
        ]
    ]];
foreach ($arr3 as $k=>$v){
    echo 'name: '.$v['name'].'<br>';
    echo 'number: '.$v['number'].'<br>';
    echo 'age: '.$v['age'].'<br>';
    echo 'hobbies: ';
    foreach ($v['hobbies'] as $key=>$hobbies){
        echo $hobbies.' ';
    }
    echo'<hr>';
}

?>

运行实例 »

点击 "运行实例" 按钮查看在线实例

Screen Shot 2019-11-15 at 9.21.49 PM.png


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post