close

[php]list — 把陣列中的值賦給一些變量


官方範例
<?php

$info = array('coffee', 'brown', 'caffeine');

// Listing all the variables
list($drink, $color, $power) = $info;
echo "$drink is $color and $power makes it special.\n";

輸出:coffee is brown and caffeine makes it special.

// Listing some of them
list($drink, , $power) = $info;
echo "$drink has $power.\n";

輸出:coffee has caffeine.

// Or let's skip to only the third one
list( , , $power) = $info;
echo "I need $power!\n";
輸出:I need caffeine!
?>

arrow
arrow
    全站熱搜

    stockwfj3 發表在 痞客邦 留言(0) 人氣()