If your dosomething () function returns different values, and this can be done with one shot, it is better to use the second method.
$ options = array (1,2,3,4,5); $ element_count = count ($ options);
Functions such as count () that return the same value in multiple calls can be stored in a single variable and used in a for loop.
If you are very strict about performance, use ++ $ i instead of $ i ++
source share