note 120201 added to control-structures.foreach
| From: | mustaroad | Date: | Tue, 22 Nov 2016 06:38:22 +0000 |
| Subject: | note 120201 added to control-structures.foreach | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-207459@lists.php.net to get a copy of this message | ||
in foreach if you want to iterate through a specific column in a nested arrays for example:
$arr = array(
[1, 2, 3, 4],
[14, 6, 7, 6],
[10, 2 ,3 , 2],
);
when we want to iterate on the third column we can use:
foreach( $arr as list( , , $a)) {
echo "$a\n";
}
this will print:
3
7
3
----
Server IP: 72.52.91.14
Probable Submitter: 37.236.112.33
----
Manual Page -- http://php.net/manual/en/control-structures.foreach.php
Edit -- https://master.php.net/note/edit/120201
Del: integrated -- https://master.php.net/note/delete/120201/integrated
Del: useless -- https://master.php.net/note/delete/120201/useless
Del: bad code -- https://master.php.net/note/delete/120201/bad+code
Del: spam -- https://master.php.net/note/delete/120201/spam
Del: non-english -- https://master.php.net/note/delete/120201/non-english
Del: in docs -- https://master.php.net/note/delete/120201/in+docs
Del: other reasons-- https://master.php.net/note/delete/120201
Reject -- https://master.php.net/note/reject/120201
Search -- https://master.php.net/manage/user-notes.php