Cost of painting n * m grid | Function to return the minimum cost ; Driver code
< ? php function getMinCost ( $ n , $ m ) { $ cost = ( $ n - 1 ) * $ m + ( $ m - 1 ) * $ n ; return $ cost ; } $ n = 4 ; $ m = 5 ; echo getMinCost ( $ n , $ m ) ; ? >