PHP 8.5.0 RC 2 available for testing

Voting

: max(three, six)?
(Example: nine)

The Note You're Voting On

onlyranga at gmail dot com
11 years ago
[Editor's note: array at from dot pl had pointed out that count() is a cheap operation; however, there's still the function call overhead.]

If you want to run through large arrays don't use count() function in the loops , its a over head in performance, copy the count() value into a variable and use that value in loops for a better performance.

Eg:

// Bad approach

for($i=0;$i<count($some_arr);$i++)
{
// calculations
}

// Good approach

$arr_length = count($some_arr);
for($i=0;$i<$arr_length;$i++)
{
// calculations
}

<< Back to user notes page

AltStyle によって変換されたページ (->オリジナル) /