text: Undulating numbers | PHP program to check whether a number is undulating or not ; Considering the definition with restriction that there should be at least 3 digits ; Check if all alternate digits are same or not . ; Driver code
code: < ? php function isUndulating ( $ n ) { if ( strlen ( $ n ) <= 2 ) return false ; for ( $ i = 2 ; $ i < strlen ( $ n ) ; $ i ++ ) if ( $ n [ $ i - 2 ] != $ n [ $ i ] ) false ; return true ; } $ n = "1212121" ; if ( isUndulating ( $ n ) ) echo ( " Yes " ) ; else echo ( " No " ) ; ? >