Last active
December 18, 2017 20:40
-
-
Save yphastos/fb4d0eea90ca8f4b2808857f6704dd59 to your computer and use it in GitHub Desktop.
convert array keys to lowercase
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
// just for fun, because there already is a native function: | |
// array array_change_key_case( array $array [, int $case = CASE_LOWER ] ) // || CASE_UPPER | |
function _array_keys_lower($datos){ | |
// convertir keys de MAY a min | |
foreach($datos as $k => $v){ | |
if($k == 0){ | |
$cols = array_keys($v); | |
// pr($cols,"cols"); | |
$Mm = array(); | |
foreach($cols as $c => $col){ | |
$Mm[$col] = strtolower($col); | |
} | |
// pr($Mm,"Mm"); | |
} | |
foreach($Mm as $M => $m){ | |
$datos[$k][$m] = $v[$M]; | |
unset($datos[$k][$M]); | |
} | |
} | |
return $datos; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment