Assume you want to be all your are keys in a certain case, either uppercase or lowercase. You can loop your keys and change the keys but this can be done more efficient.
$myArray = array("name" => "John Doe", "Age" => 40, "emAil" => "john@email.com");
$newArray = [];
foreach($myArray as $key => $value){
$key = strtoupper($key);
$newArray[$key] = $value;
}
$myArray = $newArray;
$outputOriginal = json_encode($myArray);
$myArray = array("name" => "John Doe", "Age" => 40, "emAil" => "john@email.com");
$myArray = array_change_key_case($myArray, CASE_UPPER);
$outputRefactored = json_encode($myArray);
LLoadout is your loadout for Laravel, helping you kickstart your development process. Besides this refactoring site we also make some cool packages and video tutorials !
Go to LLoadout on github