How to modify the case of an array’s keys In PHP, there is a specific buildin function. Function name :
array_change_key_case()
This function have two parameters.
Array – [the array whose keys will be changed case by case],
Case Type – [In this case there will be 2 wells. Ex: CASE_UPPER and CASE_LOWER]
However, CASE_LOWER is set the case type by default.
Example
<?php $input_array = array("name" => 'Istiaq Nirab', "Age" => "18+"); print_r(array_change_key_case($input_array, CASE_UPPER)); ?>
Result
Array ( [NAME] => Istiaq Nirab [AGE] => 18+ )
Thanks 😊
Top comments (0)