Given two unsorted arrays , find all pairs whose sum is x | Function to print all pairs in both arrays whose sum is equal to given value x ; Driver code
< ? php function findPairs ( $ arr1 , $ arr2 , $ n , $ m , $ x ) { for ( $ i = 0 ; $ i < $ n ; $ i ++ ) for ( $ j = 0 ; $ j < $ m ; $ j ++ ) if ( $ arr1 [ $ i ] + $ arr2 [ $ j ] == $ x ) echo $ arr1 [ $ i ] . " ▁ " . $ arr2 [ $ j ] . " STRNEWLINE " ; } $ arr1 = array ( 1 , 2 , 3 , 7 , 5 , 4 ) ; $ arr2 = array ( 0 , 7 , 4 , 3 , 2 , 1 ) ; $ n = count ( $ arr1 ) ; $ m = count ( $ arr2 ) ; $ x = 8 ; findPairs ( $ arr1 , $ arr2 , $ n , $ m , $ x ) ; ? >