array_uintersect_uassoc() Compare arrays, and returns the matches (compare keys and values, using two user-defined key comparison functions) array_unique() Removes duplicate values from an array array_unshift() Adds one or more elements to the beginning of an array array_values() Returns all ...
The array functions are part of the PHP core. There is no installation needed to use these functions.PHP Array FunctionsFunctionDescription array() Creates an array array_change_key_case() Changes all keys in an array to lowercase or uppercase array_chunk() Splits an array into chunks of ...
PHP Array FunctionsPHP has a set of built-in functions that you can use on arrays.FunctionDescription array() Creates an array array_change_key_case() Changes all keys in an array to lowercase or uppercase array_chunk() Splits an array into chunks of arrays array_column() Returns the ...
PHP String PHP Operators PHP If...Else PHP Switch PHP Arrays PHP Looping PHP Functions PHP Forms PHP $_GET PHP $_POST PHP Advanced PHP Date PHP Include PHP File PHP File Upload PHP Cookies PHP Sessions PHP E-mail PHP Secure E-mail PHP Error PHP Exception PHP Filter PHP Database MySQL...
<?php $a1=array("Dog","Cat"); $a2=array("Fido","Missy"); array_multisort($a1,$a2); print_r($a1); print_r($a2); ?> The output of the code above will be: Array ( [0] => Cat [1] => Dog ) Array ( [0] => Missy [1] => Fido ) ...
❮ PHP Array ReferenceExampleGet your own PHP ServerCompare the keys and values of two arrays (using two user-defined functions for comparison) and return the differences:<?php function myfunction_key($a,$b){if ($a===$b) { return 0;...
Filter the values of an array using a callback function: <?phpfunction test_odd($var) { return($var & 1); }$a1=array(1,3,2,3,4);print_r(array_filter($a1,"test_odd"));?> Try it Yourself » Definition and UsageThe array_filter() function filters the values of an array us...
Return Value:Returns TRUE if the value is found in the array, or FALSE otherwise PHP Version:4+ PHP Changelog:PHP 4.2: The search parameter may now be an array More Examples Example Using all parameters: <?php $people =array("Peter","Joe","Glenn","Cleveland",23); ...
<?php $cars=array("Volvo","BMW","Toyota"); echo"I like ". $cars[0] .", ". $cars[1] ." and ". $cars[2] ."."; ?> Try it Yourself » Definition and Usage The array() function is used to create an array. In PHP, there are three types of arrays: ...
<?php $a1=array("red","green","blue","yellow");$a2=array("red","green","blue"); $result=array_diff_key($a1,$a2);print_r($result);?> Try it Yourself » ExampleCompare the keys of three arrays, and return the differences:<?php ...