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()
❮ 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;...
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 ...
Note:You can assign the sorting order and the sorting type parameters after each array. If you don't, each array parameter uses the default values. Example 1 <?php $a1=array("Dog","Cat"); $a2=array("Fido","Missy"); array_multisort($a1,$a2); print_r($a1); print_r($a2); ?
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 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 Array ReferenceExample Send the values in an array to a user-defined function and return a string: <?php function myfunction($v1,$v2) { return $v1 . "-" . $v2; } $a=array("Dog","Cat","Horse"); print_r(array_reduce($a,"myfunction")); ?> Try it Yourself »...
❮ PHP Array ReferenceExampleGet your own PHP ServerCompare the values of two arrays (use a user-defined function to compare the values) and return the matches:<?php function myfunction($a,$b){if ($a===$b) { return 0; } return ($a>$b)?1:-1;...
<?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: ...
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.