Skip to content

Instantly share code, notes, and snippets.

@whoisryosuke
Created May 12, 2018 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whoisryosuke/7009b7a750c390d74b014e1e9a6996e1 to your computer and use it in GitHub Desktop.
Save whoisryosuke/7009b7a750c390d74b014e1e9a6996e1 to your computer and use it in GitHub Desktop.
Specify the variables for keys in arrays in PHP7 -- found via: https://blog.frankdejonge.nl/array-destructuring-in-php/
<?php
$members = [
[1, 'Seb'],
[2, 'Alex'],
[3, 'Brent'],
];
foreach ($members as [$id, $name]) {
// do stuff with $id and $name
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment