PHP学习笔记——数组

 <?php
    // 在此之前的$addresses没有定义
    echo $addresses[0]; // 无输出
    echo $addresses; // 无输出
    $addresses[0] = "100@100.com";
    $addresses[1] = "111@111.com";
    $addresses[2] = "222@222.com";
    echo $addresses;
    $addresses = array("100@100.com","111@111.com","222@222.com");
    echo $addresses;
    $price['apple'] = 1.00;
    $price['banana'] = 2.00;
    $price['oranger'] = 3.00;
    echo $price;
    $price = array(
        'apple' => 1.00,
        'banana' => 2.00,
        'oranger' => 3.00
    );
    echo $price;
    $number = array(); /* 创建空数组 */
    $color = array('Mike' => "black",'0' => "Brown",'1' => "Green"); /* 错误的代码,后面的键是从0开始的整数 */
    $color = array('Mike' => "black","Brown","Green");
    $family = array('Mike','Depp','Elliot');
    $family[] = "Taylor"; /* $family[3]是"Taylor" */
    $person = array('name' => "Niko");
    $person[] = "S1mple"; /* $person[0] 是 "S1mple" */
    $number = range(2, 5); /* $number = array(2, 3, 4, 5); */
    $letters = range('a', 'z'); /* $letters 保存了字母表 */
    $size = count($family); /* $size = 4 */
    $scores = array(5, 10); 
    $padded = array_pad($scores, 5, 0); /* $padded = array(5, 10, 0, 0, 0); */
    $padded = array_pad($scores, -5, 1); /* $padded = array(1, 1, 1, 5, 10); */
    $values = range('a','e');
    list($m,$n,$o) = $values; /* $m = "a" , $n = "c" , $o = "e"; */
    $order =   array("Tom","Dick","Jack","Helen");
    list($second,$third) = array_slice($order,1,2); /* $second = "Dick",$third = "Jack"; */
    ?>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值