How to change the case of keys or values in an associative array in PHP?

To change the case of keys or values in an associative array in PHP, you can use a loop to iterate through each element of the array and perform the case change operation.

Here's an example code that changes the keys and values to uppercase:

$array = array( 'name' => 'John', 'age' => 25, 'city' => 'New York' ); $newArray = array(); foreach ($array as $key => $value) { $newKey = strtoupper($key); $newValue = strtoupper($value); $newArray[$newKey] = $newValue; } print_r($newArray);

Output:

Array ( [NAME] => JOHN [AGE] => 25 [CITY] => NEW YORK )

Similarly, you can use strtolower() function instead of strtoupper() to change the case to lowercase.