Last active
December 14, 2017 09:16
-
-
Save Jul10l1r4/eff17cb350811a8241cf20c1a2db1890 to your computer and use it in GitHub Desktop.
Array_reduce1.php created by Jul10l1r4 - https://repl.it/@Jul10l1r4/Arrayreduce1php
This file contains hidden or 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 | |
$users = [ | |
[ 'idade' => 29, 'nome' => 'Marcos lucim' ], | |
[ 'idade' => 20, 'nome' => 'Marcelo ' ], | |
[ 'idade' => 50, 'nome' => 'Marcos dougras' ], | |
]; | |
function passa ( $val, $w ){ | |
$val["idade"] += $w["idade"];// aqui ele vai pegar o valor do array e irá somar. | |
return $val; | |
} | |
$val_saida = array_reduce( $users, "passa" ); | |
// Mudei o nome da variavel, por motivo de futuras alterações | |
print_r($val_saida); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment