How to use array change key case in PHP

In this article, I will explain how the array_change_key_case() function can be used in PHP.
  • 2111

array_change_key_case() function in PHP

  • The array_change_key_case() function is used to change all keys of a given array to lower case or upper case.

Syntax

array_change_key_case(array,case)

Parameter

array array is required parameter. Specifies the array to use

case case is optional parameter. case either

  • CASE_LOWER -the array return key values in lower case.
  • CASE_UPPER - the array return key values in upper case.

Example

The following example show to how the array_change_key_case() function can be used in PHP.

<h3 style="color: turquoise;">array_change_key_case() example in PHP</h3>

<?php 

$input_array = array("India"=> 150,"england" => 100); 

print_r(array_change_key_case($input_array,CASE_UPPER)); 

?>

 

Output

upper case array.jpg

You may also want to read these related articles here
 
Ask Your Question 
 
Got a programming related question? You may want to post your question here
 

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.