Created
June 27, 2017 20:44
-
-
Save stevenwadejr/bcb4222dbbed85e1dc581a1b026f2d07 to your computer and use it in GitHub Desktop.
Using `list()` inside of a `foreach` loop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$identifiers = [ | |
['contact', 1], | |
['company', 2], | |
['contact', 4], | |
['company', 3] | |
]; | |
foreach ($identifiers as list($type, $id)) { | |
echo ucfirst($type) . ' - ' . $id . "\n"; | |
} | |
?> | |
Outputs: | |
Contact - 1 | |
Company - 2 | |
Contact - 4 | |
Company - 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment