Skip to content

Instantly share code, notes, and snippets.

@chrisciampoli
Created April 27, 2015 20:45
Show Gist options
  • Save chrisciampoli/f035673407656416b833 to your computer and use it in GitHub Desktop.
Save chrisciampoli/f035673407656416b833 to your computer and use it in GitHub Desktop.
Remove KEYS from PHP to JSON
private function fix_keys($array) {
$numberCheck = false;
foreach ($array as $k => $val) {
if (is_array($val)){
$array[$k] = $this->fix_keys($val);
}
if(is_numeric($k)){
$numberCheck = true;
}
}
if($numberCheck === true){
return array_values($array);
} else {
return $array;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment