Created
December 31, 2013 11:52
-
-
Save davidchc/8195711 to your computer and use it in GitHub Desktop.
Exemplo de utilização do array_map
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 | |
//Arra | |
$arr = array( | |
array(1256, 4576, 12566), | |
array('dwdwdw', 'ggggggggg', 'deefefefef') | |
); | |
//Cria uma função para callback | |
function associateMerge($arrayOne, $arrayTwo){ | |
return array('id' => $arrayOne, 'nome' => $arrayTwo); | |
} | |
//Usar o array_map, e passando os arrays para associar | |
$ordenar = array_map('associateMerge', $arr[0],$arr[1]); | |
echo '<pre>'; | |
print_r($ordenar); | |
echo '</pre>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment