Split the array into odd number of segments of odd lengths | Function to check ; Check the result by processing the first & last element and size ; Driver code
< ? php function checkArray ( $ arr , $ n ) { return ( $ arr [ 0 ] % 2 ) && ( $ arr [ $ n - 1 ] % 2 ) && ( $ n % 2 ) ; } $ arr = array ( 1 , 2 , 3 , 4 , 5 ) ; $ n = sizeof ( $ arr ) ; echo checkArray ( $ arr , $ n ) ; ? >