<?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";
// Listing some of them
list($drink, , $power) = $info;
echo "$drink has $power.\n";
// Or let's skip to only the third one
list( , , $power) = $info;
echo "I need $power!\n";
// list() doesn't work with strings
list($bar) = "abcde";
var_dump($bar); // NULL
Warning: Undefined variable $drink in /in/IXpei on line 6
Warning: Undefined variable $color in /in/IXpei on line 6
Warning: Undefined variable $power in /in/IXpei on line 6
is and makes it special.
coffee has caffeine.
I need caffeine!
NULL
Notice: Undefined variable: drink in /in/IXpei on line 6
Notice: Undefined variable: color in /in/IXpei on line 6
Notice: Undefined variable: power in /in/IXpei on line 6
is and makes it special.
coffee has caffeine.
I need caffeine!
NULL
Output for 7.3.32 - 7.3.33, 7.4.26
is and makes it special.
coffee has caffeine.
I need caffeine!
NULL
Output for 5.1.1 - 5.1.6, 5.2.0 - 5.2.1
Notice: Undefined variable: drink in /in/IXpei on line 6
Notice: Undefined variable: color in /in/IXpei on line 6
Notice: Undefined variable: power in /in/IXpei on line 6
is and makes it special.
coffee has caffeine.
I need caffeine!
Fatal error: Invalid opcode 98/1/1. in /in/IXpei on line 17
Process exited with code 255.
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/IXpei on line 18
Process exited with code 255.
Notice: Undefined variable: drink in /in/IXpei on line 6
Notice: Undefined variable: color in /in/IXpei on line 6
Notice: Undefined variable: power in /in/IXpei on line 6
is and makes it special.
coffee has caffeine.
I need caffeine!
NULL