Den tor. 21. feb. 2019 kl. 14.16 skrev Chris Riley <[email protected]>:
>
> Hi internals,
>
> I'd like to propose opening an rfc to make the following syntax legal:
>
> foreach($array as (int) $i) {}
How would this interact with the foreach-list syntax?
$data = [
["id" => 1, "name" => 'Tom'],
["id" => 2, "name" => 'Fred'],
];
foreach ($data as ["id" => $id, "name" => $name]) {
echo "id: $id, name: $name\n";
}
Having something like:
foreach ($data as (int) ["id" => $id, "name" => $name]) {
Would then make both $id and $name integers?
--
regards,
Kalle Sommer Nielsen
[email protected]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php