Skip to content

Instantly share code, notes, and snippets.

@dilab
Created September 6, 2015 03:36
Show Gist options
  • Save dilab/f60279ec5c717778b7e5 to your computer and use it in GitHub Desktop.
Save dilab/f60279ec5c717778b7e5 to your computer and use it in GitHub Desktop.
Convert array to new format, but with the same data
$oldFormat = array(
'male' => 'Male',
'female' => 'Female'
);
$newFormat = array_map(function($value, $label) {
return array(
'label' => $label,
'value' => $value,
);
}, array_keys($oldFormat), array_values($oldFormat));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment