diff --git a/language/control-structures/for.xml b/language/control-structures/for.xml
index 4eea2ba400..1ccec7d4be 100644
--- a/language/control-structures/for.xml
+++ b/language/control-structures/for.xml
@@ -122,11 +122,11 @@ endfor;
* when running through the for loop.
*/
$people = Array(
- Array('name' => 'Kalle', 'salt' => 856412),
- Array('name' => 'Pierre', 'salt' => 215863)
- );
+ Array('name' => 'Kalle', 'salt' => 856412),
+ Array('name' => 'Pierre', 'salt' => 215863)
+);
-for($i = 0; $i < sizeof($people); ++$i)
+for($i = 0; $i < count($people); ++$i)
{
$people[$i]['salt'] = rand(000000, 999999);
}
@@ -136,11 +136,11 @@ for($i = 0; $i < sizeof($people); ++$i)
- The problem lies in the second for expression. This code can be slow
+ The problem lies in the second for expression. This code can be slow
because it has to calculate the size of the array on each iteration.
- Since the size never change, it can be optimized easily using an
- intermediate variable to store the size and use in the loop instead
- of sizeof. The example below illustrates this:
+ Since the size never changes, it can be optimized easily using an
+ intermediate variable to store the size and use in the loop instead
+ of count. The example below illustrates this:
@@ -148,11 +148,11 @@ for($i = 0; $i < sizeof($people); ++$i)
'Kalle', 'salt' => 856412),
- Array('name' => 'Pierre', 'salt' => 215863)
- );
+ Array('name' => 'Kalle', 'salt' => 856412),
+ Array('name' => 'Pierre', 'salt' => 215863)
+);
-for($i = 0, $size = sizeof($people); $i < $size; ++$i)
+for($i = 0, $size = count($people); $i < $size; ++$i)
{
$people[$i]['salt'] = rand(000000, 999999);
}