PHP array_change_key_case() ফাংশন

উদাহরণ

একটি অ্যারের সকল কী শব্দকে আপারকেস করা:

<?php
$age=array("Bill"=>"60","Steve"=>"56","Mark"=>"31");
print_r(array_change_key_case($age,CASE_UPPER));
?>

Run Instance

সংজ্ঞা ও ব্যবহার

array_change_key_case() ফাংশন একটি অ্যারের সকল কী শব্দকে আপারকেস বা লোকেস করে।

The numeric indices of the array do not change. If the optional parameter is not provided (i.e., the second parameter), it is converted to lowercase by default.

Tips and Comments

Note:If two or more keys are the same when running the function, the last element will overwrite other elements (see Example 2).

Syntax

array_change_key_case(array,case);
Parameter Description
array Required. Specifies the array to be used.
case

Optional. Possible values:

  • CASE_LOWER - Default value. Convert the keys of the array to lowercase letters.
  • CASE_UPPER - Convert the keys of the array to uppercase letters.

Technical Details

Return Value: Returns an array with keys in uppercase or lowercase, or if array Returns FALSE if it is not an array.
PHP Version: 4.2+

More Examples

Example 1

Convert all keys of the array to lowercase letters:

<?php
$age=array("Bill"=>"60","Steve"=>"56","Mark"=>"31");
print_r(array_change_key_case($age,CASE_LOWER));
?>

Run Instance

Example 2

If there are two or more keys that are equal after running array_change_key_case() (such as "b" and "B"), the last element will overwrite other elements:

<?php
$pets=array("a"=>"Cat","B"=>"Dog","c"=>"Horse","b"=>"Bird");
print_r(array_change_key_case($pets,CASE_UPPER));
?>

Run Instance