Find the intersection of two Matrices | Function to print the resultant matrix ; print element value for equal elements else * ; Driver Code
< ? php function printIntersection ( $ A , $ B ) { $ N = 4 ; $ M = 4 ; for ( $ i = 0 ; $ i < $ M ; $ i ++ ) { for ( $ j = 0 ; $ j < $ N ; $ j ++ ) { if ( $ A [ $ i ] [ $ j ] == $ B [ $ i ] [ $ j ] ) echo $ A [ $ i ] [ $ j ] . " ▁ " ; else echo " * ▁ " ; } echo " STRNEWLINE " ; } } $ A = array ( array ( 2 , 4 , 6 , 8 ) , array ( 1 , 3 , 5 , 7 ) , array ( 8 , 6 , 4 , 2 ) , array ( 7 , 5 , 3 , 1 ) ) ; $ B = array ( array ( 2 , 3 , 6 , 8 ) , array ( 1 , 3 , 5 , 2 ) , array ( 8 , 1 , 4 , 2 ) , array ( 3 , 5 , 4 , 1 ) ) ; printIntersection ( $ A , $ B ) ; ? >