Check if all the palindromic sub | Function to check if the string is palindrome ; Function that checks whether all the palindromic sub - strings are of odd length . ; Creating each substring ; If the sub - string is of even length and is a palindrome then , we return False ; Driver code
< ? php function checkPalindrome ( $ s ) { for ( $ i = 0 ; $ i < strlen ( $ s ) ; $ i ++ ) { if ( $ s [ $ i ] != $ s [ strlen ( $ s ) - $ i - 1 ] ) return false ; } return true ; } function CheckOdd ( $ s ) { $ n = strlen ( $ s ) ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) { $ x = " " ; for ( $ j = $ i ; $ j < $ n ; $ j ++ ) { $ x = $ x . $ s [ $ i ] ; if ( strlen ( $ x ) % 2 == 0 && checkPalindrome ( $ x ) == true ) return false ; } } return true ; } $ s = " geeksforgeeks " ; if ( CheckOdd ( $ s ) ) echo " YES " ; else echo " NO " ; ? >