note 126405 added to control-structures.foreach

From: Date: Thu, 09 Sep 2021 07:42:22 +0000
Subject: note 126405 added to control-structures.foreach
Groups: php.notes 
Request: Send a blank email to php-notes+get-216934@lists.php.net to get a copy of this message
It should be mentioned, that short list syntax is already implemented since 7.1 and the list keyword can be omitted by using brackets. See https://wiki.php.net/rfc/short_list_syntax <?php $heroes = [ ['Batman', 'Bruce Wayne'], ['Flash', 'Barry Allen'], ['Superman', 'Clark Kent'], ]; foreach ($heroes as [$hero, $realname]) { echo "$hero is $realname\n"; } ?> Will output Batman is Bruce Wayne Flash is Barry Allen Superman is Clark Kent ---- Server IP: 45.112.84.4 Probable Submitter: 45.112.85.242 (proxied: 2003:ed:8f04:2938:1791:df2a:9c15:f8fc) ---- Manual Page -- https://php.net/manual/en/control-structures.foreach.php Edit -- https://main.php.net/note/edit/126405 Del: integrated -- https://main.php.net/note/delete/126405/integrated Del: useless -- https://main.php.net/note/delete/126405/useless Del: bad code -- https://main.php.net/note/delete/126405/bad+code Del: spam -- https://main.php.net/note/delete/126405/spam Del: non-english -- https://main.php.net/note/delete/126405/non-english Del: in docs -- https://main.php.net/note/delete/126405/in+docs Del: other reasons-- https://main.php.net/note/delete/126405 Reject -- https://main.php.net/note/reject/126405 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#216934) next »