Skip to content

Instantly share code, notes, and snippets.

@joelhinz
Created September 12, 2018 11:23
Show Gist options
  • Save joelhinz/fc90db2f8039cc0e98a3612ca0fc438a to your computer and use it in GitHub Desktop.
Save joelhinz/fc90db2f8039cc0e98a3612ca0fc438a to your computer and use it in GitHub Desktop.
<?php
// vanliga arrayer
$capitals = [];
foreach ($countries as $country) {
$capitals[] = $country->capital;
}
// collections
$capitals = $countries->map(function ($country) {
return $country->capital;
});
// collections med higher order messaging
$capitals = $countries->map->capital;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment