assign array to variable php

Solutions on MaxInterview for assign array to variable php by the best coders in the world

showing results for - "assign array to variable php"
Emelie
22 May 2016
1$info = array('coffee', 'brown', 'caffeine');
2
3// Listing all the variables
4list($drink, $color, $power) = $info;
5echo "$drink is $color and $power makes it special.\n";
6
7// Listing some of them
8list($drink, , $power) = $info;
9echo "$drink has $power.\n";
10
11// Or let's skip to only the third one
12list( , , $power) = $info;
13echo "I need $power!\n";
14
15// list() doesn't work with strings
16list($bar) = "abcde";
17var_dump($bar); // NULL