Created
May 12, 2018 20:23
-
-
Save whoisryosuke/61c585ffe1f465388646193eb244f040 to your computer and use it in GitHub Desktop.
Specify the variables for specific keys in arrays in PHP7 -- found via: https://blog.frankdejonge.nl/array-destructuring-in-php/
This file contains 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 | |
$members = [ | |
['id' => 1, 'name'=> 'Seb', 'twitter' => '@sebdedeyne' ], | |
['id' => 2, 'name'=> 'Alex', 'twitter' => '@alexvanderbist'], | |
['id' => 3, 'name'=> 'Brent', 'twitter' => '@brendt_gd'], | |
]; | |
foreach ($members as ['twitter' => $twitterHandle, 'name' => $firstName]) { | |
// do stuff with $twitterHandle and $firstName | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment