array definition in php code example
Example 1: array in php
<?php
$cars = array("Maserati", "Porsche", "BMW");
echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . ".";
?>
Example 2: assign array to variable php
$info = array('coffee', 'brown', 'caffeine');
list($drink, $color, $power) = $info;
echo "$drink is $color and $power makes it special.\n";
list($drink, , $power) = $info;
echo "$drink has $power.\n";
list( , , $power) = $info;
echo "I need $power!\n";
list($bar) = "abcde";
var_dump($bar);