Created
April 7, 2017 09:55
-
-
Save kraizt/ee57b881c3e1fad63a60ccc5ffbee759 to your computer and use it in GitHub Desktop.
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 | |
$users = [ | |
[ | |
'id' => 1, | |
'name' => 'Adimas Lutfi Wicaksono', | |
'gender' => 1, | |
], | |
[ | |
'id' => 2, | |
'name' => 'Salman Alfarisi', | |
'gender' => 1, | |
], | |
[ | |
'id' => 3, | |
'name' => 'Muhammad Sholeh', | |
'gender' => 1, | |
], | |
[ | |
'id' => 4, | |
'name' => 'Yadi Cahyadi', | |
'gender' => 1, | |
], | |
[ | |
'id' => 5, | |
'name' => 'Maya Maulani', | |
'gender' => 2, | |
], | |
]; | |
// http://www.php.net/manual/en/language.references.pass.php | |
// http://id1.php.net/manual/en/function.array-walk.php | |
array_walk ( $users, function (&$key) { | |
$key["gender"] = $key["gender"] == 1 ? "Male" : "Female"; | |
}); | |
print_r($users); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment