Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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