It Returns an array of the parameters. The parameters can be given an index with the => operator
Parameters
Return Values: It returns an array of the parameters.
array(key1 => value1, key2 => value2...)
<?php
$array_val= array("val1"=>"computer", "val2"=>"laptop", "val3"=>"mouse");
print_r($array_val);
?>
Output :
Array ( [val1] => computer [val2] => laptop [val3] => mouse )
It returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is.
Parameters
Return Values: It returns an array with its keys lower or uppercased, or false if the input is not an array.
array array_change_key_case ( array $input [, int $case] )
<?php
$inputVal = array("FirSt"=> 100, "SecOnd" => 40);
print_r(array_change_key_case($inputVal, CASE_UPPER));
?>
Output : Array ( [FIRST] => 100 [SECOND] => 40 )
Parameters
Return Values: It returns an associative array of values from the input as keys and their count as value.
array array_count_values ( array $input );
<?php
$input = array("orange", "mango", "banana", "orange" );
print_r(array_count_values($input));
?>
Output : Array ( [orange] => 2 [mango] => 1 [banana => 1 )
It creates an array by using the values from the keys array as keys and the values from the values array as the corresponding values.
Parameters
Return Values: It returns the combined array, FALSE if the number of elements for each array isn't equal or if the arrays are empty.
Syntax
array array_combine ( array $keys, array $values );
<?php
$abc = array("green","red","yellow");
$bcd = array("mango","apple", "banana");
$cde = array_combine($abc, $bcd);
print_r($cde);
?>
Output : Array([green] => mango [red] => apple [yellow] => banana)
It chunks an array into a size large chunks. The last chunk may contain less than size elements.
Parameters
Return Values: It returns a multidimensional numerically indexed array
Syntax
array array_chunk ( array $input, int $size [, bool $preserve_keys] );
<?php
$input = array("apple","mango", "orange","banana","grapes");
print_r(array_chunk($input, 4));
print_r(array_chunk($input, 2, true));
?>
Output : Array ( [0] => Array ( [0] => apple[1] => mango[2] => orange[3] => banana) [1] => Array ( [0] => grapes) ) Array ( [0] => Array ( [0] => apple[1] => mango) [1] => Array ( [2] => orange[3] => banana) [2] => Array ( [4] => grapes) )
© 2024 Easy To Learning. All Rights Reserved | Design by Easy To Learning