Doc #80639 [Com]: [TR] foreach sample code getting error
| From: | summerdevon40 at gmail dot com | Date: | Fri, 29 Jan 2021 07:46:28 +0000 |
| Subject: | Doc #80639 [Com]: [TR] foreach sample code getting error | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-18468@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80639&edit=1
ID: 80639
Comment by: summerdevon40 at gmail dot com
Reported by: guvenacar at hotmail dot com
Summary: [TR] foreach sample code getting error
Status: Verified
Type: Documentation Problem
Package: Translation problem
Operating System: windows
PHP Version: 8.0.1
Block user comment: N
Private report: N
New Comment:
First, I assume the correct syntax for the loop is for(int i : primes){ . You cannot modify a list
while iterating through the elements using a foreach .
https://www.myaccountaccess.bid/
Previous Comments:
------------------------------------------------------------------------
[2021-01-18 08:55:40] guvenacar at hotmail dot com
Description:
------------
---
From manual page: https://php.net/control-structures.foreach
---
Below code that in Turkish page, getting error when testing
Parse error: syntax error, unexpected token "=" in C:\xampp\htdocs\VSCodeTest\index.php on
line 4
Test script:
---------------
<?php
$dizi = array("bir", "iki", "üç");
foreach ($arr as &$value) {
deÄer = deÄer * 2;
}
// $dizi Åimdi array(2, 4, 6, 8)
// unset($deÄer) olmaksızın, $deÄer hala son öÄeye gösterimli olur: $dizi[3]
foreach ($dizi as $key => $deÄer) {
// $dizi[3] artık $dizi içindeki her deÄerle güncellenecek
echo "{$key} => {$deÄer} ";
print_r($dizi);
}
// ...ikinciden son deÄere kadar son deÄere kopyalanacak.
// çıktı:
// 0 => 2 Array ( [0] => 2, [1] => 4, [2] => 6, [3] => 2 )
// 1 => 4 Array ( [0] => 2, [1] => 4, [2] => 6, [3] => 4 )
// 2 => 6 Array ( [0] => 2, [1] => 4, [2] => 6, [3] => 6 )
// 3 => 6 Array ( [0] => 2, [1] => 4, [2] => 6, [3] => 6 )
?>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80639&edit=1