Last active
August 29, 2015 14:11
-
-
Save sbruner/7e6e2f897208d3d50cc5 to your computer and use it in GitHub Desktop.
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 | |
function parse_piklist_array($array) { | |
if ( empty($array) ) | |
return array(); | |
$keys = array_keys($array); | |
if ( empty($keys) ) | |
return array(); | |
$results = $values = array(); | |
$count = count($array[$keys[0]]); | |
for ($index = 0; $index < $count; $index++) { | |
foreach($keys as $key_index => $key) { | |
$value = ( isset($array[$key][$index]) ) ? $array[$key][$index] : null; | |
if ( is_array($value) && !( isset($value[0][0]) || empty($value[0]) ) ) { | |
$values[$key] = parse_piklist_array($value, true); | |
} else | |
$values[$key] = $value; | |
} | |
$results[] = $values; | |
} | |
return $results; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment