note 34793 deleted from function.each by didou

From: Date: Wed, 06 Aug 2003 23:25:59 +0000
Subject: note 34793 deleted from function.each by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-53538@lists.php.net to get a copy of this message
Note Submitter: sly1024@freemail.hu ---- Hi! I just want to know why does everybody use this: while (list ($key, $val) = each ($array)) { ... } instead of this: foreach ($array as $key => $val) { ... } Because i think the latter is much prettier,shorter and easier! P.S. Moreover in the first case you have to reset() the array to make it work "properly" (if you want to go through all elements from the first), but in the second it's done automatically! Sly

« previous php.notes (#53538) next »