pTutorial

New way to learn PHP function

PHP Array change key case function

Syntax

array_change_key_case($array [, option]);
 

Parameter Description
Array Any array variable (required)
Option Default: 0 (lowercase) 1: (uppercase) (optional)
.

Note: Default option value is zero. It is optional.

Definition

It returns an array keys lowercase or uppercase as per condition.

Usage

array_change_key_case() function is used to change the case of arrays key.

Example of array change key case function

<?php

$student = array
(
"NamE" => "JOHN", 
"RolL NumbeR" => 38
);

print_r(array_change_key_case($student,1));

?>

In above example $student is an array type variable that hold the two element.

Key of each elemnt are in toggle case, array_change_key_case is used to change the key of complete array in capital case.

More example on array change key case function

<?php

$fruit = array("ApplE" => "71", "BANANA" => 38);

print_r($fruit);

echo "
"; print_r(array_change_key_case($fruit,0)); ?>

QUOTES OF THE DAY

Knowledge without integrity is dangerous and dreadful.

LIKE ON FACEBOOK

+1 ON GOOGLE

SHARE ON TWITTER