|
|
PHP
Tutorial
10. To
change the case of the keys in a an array
In order to change the case (uppercase to lowercase)
or (lowercase to uppercase) of the keys in an associative array, the
array_change_key_case()
with input array whose keys are to case-changed and
the case to which they have to be changed like CASE_UPPER or CASE_LOWER
as arguments can be used
|
|
<?php
$input_array = array("FirSt" => 1, "SecOnd" =>
4);
print_r(array_change_key_case($input_array,
CASE_UPPER));
$input_array2=array9"HellO" => 1,"WorLD" => 2);
print_r(array_change_key_case($input_array2,CASE_LOWER));
?>
|
11.
To sort mulitple arrays at once
To sort multiple arrays at once , the multisort
function is used as follows
<?php
$arr1=array (1,7,3,4);
$arr2=array("a","b","e","d");
array_multisort($arr1,$arr2);
echo "array1:";
print_r($arr1);
echo "array2";
print_r($arr2);
?>
Go
To Index
|
|
|