From 43cfc76e3b11c16abbae196296412e33cb5e8842 Mon Sep 17 00:00:00 2001 From: Torben Wilson Date: Mon, 9 Jun 2003 07:36:01 +0000 Subject: [PATCH] Just fix one small grammatical and a couple of small presentation errors. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@130697 c90b9560-bf6c-de11-be94-00142212c4b1 --- language/control-structures.xml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/language/control-structures.xml b/language/control-structures.xml index fdd8725379..676c4afef6 100644 --- a/language/control-structures.xml +++ b/language/control-structures.xml @@ -1,5 +1,5 @@ - + Control Structures @@ -476,13 +476,13 @@ for (expr1; expr2; expr3): statement; ...; endfor; like Perl and some other languages. This simply gives an easy way to iterate over arrays. foreach works only on arrays, and will issue an error when you try to use it on a variable with a different - data type or an uninitialized variables. There are two syntaxes; the + data type or an uninitialized variable. There are two syntaxes; the second is a minor but useful extension of the first: $value) statement +foreach (array_expression as $value) statement +foreach (array_expression as $key => $value) statement ]]> @@ -514,14 +514,14 @@ foreach(array_expression as $key => $value) statement Also note that foreach operates on a copy of - the specified array, not the array itself, therefore the array - pointer is not modified as with the each - construct and changes to the array element returned are not - reflected in the original array. However, the internal pointer - of the original array is advanced with - the processing of the array. Assuming the foreach loop runs - to completion, the array's internal pointer will be at the - end of the array. + the specified array and not the array itself. Therefore, the + array pointer is not modified as with the + each construct, and changes to the array + element returned are not reflected in the original array. + However, the internal pointer of the original array + is advanced with the processing of the + array. Assuming the foreach loop runs to completion, the + array's internal pointer will be at the end of the array. @@ -584,7 +584,7 @@ $a = array (1, 2, 3, 17); $i = 0; /* for illustrative purposes only */ -foreach($a as $v) { +foreach ($a as $v) { print "\$a[$i] => $v.\n"; $i++; } @@ -598,7 +598,7 @@ $a = array ( "seventeen" => 17 ); -foreach($a as $k => $v) { +foreach ($a as $k => $v) { print "\$a[$k] => $v.\n"; } @@ -609,7 +609,7 @@ $a[0][1] = "b"; $a[1][0] = "y"; $a[1][1] = "z"; -foreach($a as $v1) { +foreach ($a as $v1) { foreach ($v1 as $v2) { print "$v2\n"; } @@ -617,7 +617,7 @@ foreach($a as $v1) { /* foreach example 5: dynamic arrays */ -foreach(array(1, 2, 3, 4, 5) as $v) { +foreach (array(1, 2, 3, 4, 5) as $v) { print "$v\n"; } ]]>