Created
September 6, 2015 03:36
-
-
Save dilab/f60279ec5c717778b7e5 to your computer and use it in GitHub Desktop.
Convert array to new format, but with the same data
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
$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