Created
July 14, 2020 02:36
-
-
Save lgedeon/bcf0d8a0906b07e534175d801b9b5bb5 to your computer and use it in GitHub Desktop.
One way to normalize one particular type of multi-dimensional array.
This file contains hidden or 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 | |
return array_merge( | |
... array_map( | |
function( $key, $values ) { | |
if ( ! is_array( $values ) ) { | |
return []; | |
} | |
return array_map( | |
function ( $value ) use ( $key ) { | |
return [ | |
'key' => $key, | |
'old_value' => $value | |
]; | |
}, | |
$values | |
); | |
}, | |
array_keys( $post_meta ), | |
$post_meta, | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment