Forums Gallery Movies File Hosting Classifieds Jokes Free Hosting Free Blogs

Go Back   BizHat Forums > Computer Forum > PHP Programming

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-03-2009, 07:30 PM
Administrator
Site Admin
 
Join Date: Sep 2003
Posts: 2,689
Default count in for loop

One simple optimization that most people miss is not using count($var) as a condition of for loops.


PHP Code:
// Wrong
for ($i 0$i count($Results); $i++)
{
// Do Something


PHP Code:
// Correct
$ResultCount count($Results);
for (
$i 0$i $ResultCount$i++)
{
// Do Something

It’s very simple, and now you’re not counting the size of the stack every time you process the loop.
__________________
BizHat Games BizHat Video
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 11:06 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0