Change language

PHP Array_uintersect () function

Syntax:
array_uintersect ($array1, $array2, $array3, ..... $arrayn, user_function
Parameters :this function takes two types of parameters. One - is a list of arrays and the other is - a user-defined function.
  • a list of arrays: this function takes a space-separated list of arrays that we want to find an intersection for. In the above syntax, a list of arrays: $array1, $array2, $array3,… .. $arrayn. It can take any the number of space-separated arrays with a minimum value of 2.
  • user_function:is a string type parameter that is the name of a user-defined function. The function returns 0 if the values ​​in its parameter are the same, returns 1 if the first parameter is greater than the second, otherwise it returns -1.
Returned value:the function returns another array containing the entire element The s of the first array, which are present in all other arrays passed as a parameter. If none of the elements match, a NULL array is returned.Examples:
Input: $a1 = array ("a" = > "striver", "b" = > "engineer", "d" = > "raj") $a2 = array ("d" = > "articles", "e" = > "raj", "f" = > "coding") Output : Array ([d] = > raj) Input: $a1 = array ("1" = > "engineer", "2" = > "for", "3" = > "geek", "4 "= >" coding ") $a2 = array (" 1 "= >" engineer "," 2 "= >" for "," 3 "= >" php "," 4 "= >" coding "," 5 "= >" ide ") $a3 = array (" 6 "= >" cpp "," 7 "= >" java ", 8 = >" engineer ") Output: Array ( [1] = > engineer)
The following programs illustrate the array_uintersect() function:Program 1:PHP program to demonstrate the array_uintersect() function .
// PHP program for demonstration of work
// array_uintersect() function 
// custom function function user_function ( $a , $b ) { if ( $a === $b ) { return 0; } return ( $a > $b )? 1: -1; }  
// arrays $a1 = array ( "a" = > "striver" , "b" = > "engineer" , "d" = > "raj" ); $a2 = array ( "d" = > " articles " , " e " = > "raj" , "f" = > " coding " ); $result = array_uintersect ( $a1 , $a2 , "user_function" ); print_r ( $result ); ?>
Output:
Array ([d] = > raj)
Program 2:PHP program to demonstrate how the array_uintersect() function works with three arrays.
// PHP program for demonstration work
// array_uintersect() function with 3 arrays 
// custom function function user_function ( $a , $b ) { if ( $a === $b ) { return 0; } return ( $a > $b )? 1: -1; }  
// 3 arrays $a1 = array ( "1" = > "engineer" , "2" = > "for" , "3 " = > " geek " , "4" = > "coding" ); $a2 = array ( "1" = > " engineer " , " 2 " = > "for" , "3" = > " php " , " 4 " = > " coding " , "5" = > "ide" ); $a3 = array ( "6" = > " cpp " , " 7 " = > "java" , 8 = > "engineer" ); $result = array_uintersect ( $a1 , $a2 , $a3 , "user_function" ); print_r ( $result ); ?>
Output:
Array ([1] = > engineer)
Link :
http://php.net/manual/en/function.array-uintersect.php

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers


Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method