The built-in functions of PHP can dramatically improve
the efficiency of your code in the area of looping. When you encounter
a block of PHP code that iteratively calls a built-in function, take time to see if a more efficient way of achieving the same
task is available through a different, yet related, built-in function.
For example, it's faster to prepare a large string with UIDs and call
imap_fetch_overview once than it is to call
imap_fetch_overview repeatedly in a loop. See the user-contributed comments for the imap_fetch_overview function in the PHP manual for
more details.
Similarly, when reading large files it is far more efficient to read,
say, a line at a time (using fgets) and process that, than it
is to read and process a character at a time (using fgetc).
There are many other similar cases throughout the PHP language, depending
on exactly what your application does.