array_change_key_case() Function in PHP

What is array_change_key_case() Function?

Explanation

The "array_change_key_case" function is used to change the case of all elements in a array.

Syntax:


array_change_key_case(array,case)

In the above syntax specify the parameter "array" whose elements need to be changed, the parameter "case" can have two values "CASE_UPPER" ,"CASE_LOWER".

Example :


<?php
$a=array("a"=>"Bird","b"=>"Insect","c"=>"Mite");
print_r(array_change_key_case($a,CASE_UPPER));
?>
Result :

Array ([A] => Bird [B] => Insect [C] => Mite )

In the above example the array elements in lowercase a,b,c are changed to A, B, C in uppercase.

PHP Topics


Ask Questions

Ask Question