RE: [PHP] if else while statement speed

From: Date: Wed, 03 Sep 2003 17:31:16 +0000
Subject: RE: [PHP] if else while statement speed
Groups: php.general 
Request: Send a blank email to php-general+get-161573@lists.php.net to get a copy of this message
[snip] <?php if ($option1) { while(something()) { do_1(); } } elseif ($option2) { while (something()) { do_2(); } } // ... continue for 10 or more options... [/snip] Theoretically the second one is faster because it only executes the while loop when the condition is met. The first one will loop through all of them unless you break; after the suplied conditions.

« previous php.general (#161573) next »