note 82653 deleted from function.count by danbrown

From: Date: Fri, 09 Jan 2009 22:58:55 +0000
Subject: note 82653 deleted from function.count by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-149005@lists.php.net to get a copy of this message
Note Submitter: macnimble ---- In response to yarolan at mail dot ru: I actually find Duff's Device to be particularly useful in the example put forth by yarolan. He wrote: $arr_size=count($arr); for($i=0;$i<$arr_size;$i++) { ... } If the order of processing doesn't matter, I do this: $i = count($some_array); while ($i--): do_something_to($some_array[$i]); endwhile; If it does matter, I like this: $i = count($some_array); $some_array = array_reverse($some_array); while ($i--): do_something_to($some_array[$i]); endwhile; I have no idea if it's faster as I haven't tested it. Mostly, I just like the way it looks. ;) To email me, find me on TheHolierGrail.com or MacNimble.com

« previous php.notes (#149005) next »