Skip to content

Instantly share code, notes, and snippets.

@sbruner
Last active August 29, 2015 14:11
Show Gist options
  • Save sbruner/7e6e2f897208d3d50cc5 to your computer and use it in GitHub Desktop.
Save sbruner/7e6e2f897208d3d50cc5 to your computer and use it in GitHub Desktop.
<?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