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

?>
This entry was posted in Usefull PHP and tagged , , , , . Bookmark the permalink.

2 Responses to PHP Tutorial : List function

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

  2. Pingback: ยป PHP Tutorial : List function- Suwarto Dot Com

Leave a Reply

Your email address will not be published. Required fields are marked *

*

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