Skip to content

Instantly share code, notes, and snippets.

@tryvin
Created November 1, 2015 14:32
Show Gist options
  • Save tryvin/8c00e95e2775ed4ad757 to your computer and use it in GitHub Desktop.
Save tryvin/8c00e95e2775ed4ad757 to your computer and use it in GitHub Desktop.
Lambda example 2
<?php
$myDatabaseArray = array(
array(
'databaseId' => 1,
'databaseValue' => 'Hello'
),
array(
'databaseId' => 2,
'databaseValue' => 'World'
)
);
$toSmartyArray = array();
array_map(function($arrayElement) use(&$toSmartyArray) {
$toSmartyArray[$arrayElement['databaseId']] = $arrayElement['databaseValue'];
}, $myDatabaseArray);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment