PHP Tutorial : List function

Beeing surprised that I didn’t write here about this “cute” php function called list(). I like it a lot, it’s like the extract() function in some way if you remember.

The list() php function will assign variables in one shot to strings from arrays.

<?php
//here's the php array

$countingArray = array(1,2,3);
//here, the list function will convert 1 to $one variable, 2 to $two and 3 to $three

list("one", "two", "three") = $countingArray;

print "I am counting $one, errr I think it comes $two, and lastly $three";
//should print I am counting 1, err....comes 2 and lastly 3

?>

2 Responses to “PHP Tutorial : List function”

  1. XkiD | PHP Tutorial : List function | blog.xkid.ro Says:

    [...] the original post here: PHP Tutorial : List function Posted in PHP | Tags: called-list, function-will, list, one-variable, php-function, [...]


  2. » PHP Tutorial : List function- Suwarto Dot Com Says:

    [...] more from the original source:  » PHP Tutorial : List function Tags: change-the-light, color, easy, entries, final-step, follow-the-steps, know-layers, lcd, [...]


Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>