From d1ef2aa6728afffd46669172047d4c59d9ebf272 Mon Sep 17 00:00:00 2001 From: Etienne Kneuss Date: Sat, 10 Nov 2007 16:57:24 +0000 Subject: [PATCH] Discourage using foreacha along with array pointers, "wont fix" side effects git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@245989 c90b9560-bf6c-de11-be94-00142212c4b1 --- language/control-structures.xml | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/language/control-structures.xml b/language/control-structures.xml index 1a2771f134..f4271cf885 100644 --- a/language/control-structures.xml +++ b/language/control-structures.xml @@ -1,5 +1,5 @@ - + Control Structures @@ -540,15 +540,9 @@ foreach (array_expression as $key => $value) Unless the array is referenced, foreach operates on a copy of - 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. - + the specified array and not the array itself.foreach has + some side effets on the array pointer. Don't rely on the array pointer during + or after the foreach without resetting it.