In stead of:
for ($i < 0; $i < count($array_X); $i++) {
// do something....
}
One can do this and only one count() is executed:
for ($i < 0, $cnt = count($array_X); $i < $cnt; $i++) {
// do something....
}
I alright has a little concern when I put in that count(), or whatever expensive operation in the evaluation. But never think of this trick, even I know about I can initialize more than one value in a loop.
Comments
Leave comment
Trackback