Centrosymmetric Matrix | PHP Program to check whether given matrix is centrosymmetric or not . ; Finding the middle row of the matrix ; for each row upto middle row . ; If each element and its corresponding element is not equal then return false . ; Driver Code
< ? php function checkCentrosymmetricted ( $ n , $ m ) { $ mid_row ; if ( $ n & 1 ) $ mid_row = $ n / 2 + 1 ; else $ mid_row = $ n / 2 ; for ( $ i = 0 ; $ i < $ mid_row ; $ i ++ ) { for ( $ j = 0 ; $ j < $ n ; $ j ++ ) { if ( $ m [ $ i ] [ $ j ] != $ m [ $ n - $ i - 1 ] [ $ n - $ j - 1 ] ) return false ; } } return true ; } $ n = 3 ; $ m = array ( array ( 1 , 3 , 5 ) , array ( 6 , 8 , 6 ) , array ( 5 , 3 , 1 ) ) ; if ( checkCentrosymmetricted ( $ n , $ m ) ) echo " Yes " ; else echo " No " ; ? >