Skip to content

Instantly share code, notes, and snippets.

@kraizt
Created April 7, 2017 09:55
Show Gist options
  • Save kraizt/ee57b881c3e1fad63a60ccc5ffbee759 to your computer and use it in GitHub Desktop.
Save kraizt/ee57b881c3e1fad63a60ccc5ffbee759 to your computer and use it in GitHub Desktop.
<?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