array_change_key_case() function in php
×


array_change_key_case() function in php

2179

array_change_key_case() function of PHP is used to change the case of all keys of an array means it converts the all array keys value either in uppercase or lowercase depending on the case parameter.

It is an inbuilt function of PHP.

array_change_key_case() function syntax:

array_change_key_case ($array, $case_param);

Here

$array represents the array which keys case we want to change and $case_param represents the case type. It is an optional parameter which can be either CASE_LOWER for lowercase or CASE_UPPER for uppercase.

If we don't give this parameter then the function converts all keys value of array in lowercase.


Example:

<?php
$arr=array("raja"=>"1221","sattu"=>"1222","ram"=>"1223","pragya"=>"1224");
$new_arr=array_change_key_case($arr,CASE_UPPER);
echo "<pre>";
print_r($new_arr);
?>

Output:


Example 2:

<?php
$arr=array("RAJANI"=>"1221","Radha"=>"1222","Payal"=>"1223");
$new_arr=array_change_key_case($arr,CASE_LOWER);
echo "<pre>";
print_r($new_arr);
?>

Output:




Best WordPress Hosting


Share:


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price



Leave a Reply


Comments
    Waiting for your comments