Replace every element of the array by product of all other elements | PHP program to Replace every element by the product of all other elements ; Calculate the product of all the elements ; Replace every element product of all other elements ; Driver Code ; Print the modified array .
< ? php function ReplaceElements ( $ arr , $ n ) { $ prod = 1 ; for ( $ i = 0 ; $ i < $ n ; ++ $ i ) { $ prod *= $ arr [ $ i ] ; } for ( $ i = 0 ; $ i < $ n ; ++ $ i ) { $ arr [ $ i ] = ( int ) ( $ prod / $ arr [ $ i ] ) ; } return $ arr ; } $ arr = array ( 2 , 3 , 3 , 5 , 7 ) ; $ n = sizeof ( $ arr ) ; $ arr1 = ReplaceElements ( $ arr , $ n ) ; for ( $ i = 0 ; $ i < $ n ; ++ $ i ) { echo $ arr1 [ $ i ] . " " ; } ? >