It feels like that problem has already been solved but my search did not find a "good" solution. I have a time critical app and need to convert a typical string into an assoc array:
"appliCAation=webCALL&Arg1=ABC&arG2=xyZ&someMore=Dec-1950"
I know I can use parse_str()
for that but I would like to "normalize" the user input so that all keys are always uppercase and all values are always lowercase (and vice versa, if possible done by parameter and NOT widen the footprint of the code).
Since array_change_key_case()
does not work recursively, I search for an elegant way with few lines of code and efficient performance.
At the moment I use parse_str( strtolower( $input ), $arr );
and then loop (recursively) the array to change the keys. Unfortunately that needs two methods and "many" code lines.
Any faster / better / smaller solution for that?