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
1$myArray = array("http://www.marleenvanlook.be/admin.php","http://www.marleenvanlook.be/checklogin.php","etc");
2
3$i = 0;
4foreach($myArray as $value){
5 ${'something'.$i} = $value;
6 $i++;
7 }
8
9echo $something0; //http://www.marleenvanlook.be/admin.php
10
1$data = array(
2 'something1',
3 'something2',
4 'something3',
5);
6extract($data, EXTR_PREFIX_ALL, 'var');
7echo $var0; //Output something1
8
1$something = array(
2 'http://www.marleenvanlook.be/admin.php',
3 'http://www.marleenvanlook.be/checklogin.php',
4 'http://www.marleenvanlook.be/checkupload.php',
5 'http://www.marleenvanlook.be/contact.php',
6);
7
8foreach($something as $key => $value) {
9 $key = 'something' . $key;
10 $$key = $value;
11
12 // OR (condensed version)
13 // ${"something{$key}"} = $value;
14}
15
16echo $something2;
17// http://www.marleenvanlook.be/checkupload.php
18