+

PHP Array_uintersect_uassoc () function

Syntax:
array array_uintersect_uassoc ($array1, $array2, $array3 ..., $function_key, $function_value) 
Parameters:This function takes several parameters as above and described below:
  • array1:this is the first array that is required and is used to compare against other arrays.
  • array 2:this is the second array, which is required and is used for comparison with the first array and other arrays.
  • array3 and other arrays:these are optional parameters. This array is used for comparison with other arrays.
  • function_key:these are required parameters. This is the name of a custom function that compares array keys.
  • function_value:required parameters. This is the name of a custom function that compares array values.
Return Value:Returns an array containing all the values ​​of array1 present in all arguments.The programs below illustrate the array_uintersect_uassoc() function in PHP:Program 1: $arr1 = array ( "a" = > " green " , " b " = > "brown" , "c" = > " blue " , "red" ); $arr2 = array ( "a" = > " GREEN " , " B " = > "brown" , "yellow" , " red " ); print_r ( array_uintersect_uassoc ( $arr1 , $arr2 , "strcasecmp" , "strcasecmp" )); ?> Output:
Array ([a] = > green [b] = > brown) 
Program 2: function function_key ( $a , $b ) { if ( $a == $b ) return 0; return ( $a > $b )? eleven; } function function_value ( $a , $b ) { if ( $a == $b ) return 0; return ( $a > $b )? eleven; } $arr1 = array ( "1" = > "Geeks" , "2" = > "GeeksforGeeks" , "3" = > "Geeks1" ); $arr2 = array ( "1" = > " Geeks " , " 2 " = > "GFG" , "3" = > " Geeks1 " ); $res = array_uintersect_uassoc ( $arr1 , $arr2 , "function_key" , "function_value" ); print_r ( $res ); ?> Output:
Array ([1] = > Geeks [3] = > Geeks1) 
Link: http://php.net/manual/en/function.array-uintersect-uassoc.php
Get Solution for free from DataCamp guru