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 ...
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 ...
❮ 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;...
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 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 Reference ExampleGet your own PHP Server Start the slice from the third array element, and return the rest of the elements in the array: <?php $a=array("red","green","blue","yellow","brown"); print_r(array_slice($a,2)); ...
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 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 Array ReferenceExampleFilter 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 ...