Created
April 27, 2015 20:45
-
-
Save chrisciampoli/f035673407656416b833 to your computer and use it in GitHub Desktop.
Remove KEYS from PHP to JSON
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
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