Count of alphabets having ASCII value less than and greater than k | Function to count the number of characters whose ascii value is less than k ; Initialising the count to 0 ; Incrementing the count if the value is less ; return the count ; Driver code
< ? php function CountCharacters ( $ str , $ k ) { $ cnt = 0 ; $ len = strlen ( $ str ) ; for ( $ i = 0 ; $ i < $ len ; $ i ++ ) { if ( $ str [ $ i ] < chr ( $ k ) ) $ cnt += 1 ; } return $ cnt ; } $ str = " GeeksForGeeks " ; $ k = 90 ; $ count = CountCharacters ( $ str , $ k ) ; echo ( " Characters ▁ with ▁ ASCII ▁ values " . " ▁ less ▁ than ▁ K ▁ are ▁ " . $ count ) ; echo ( " Characters with ASCII values " ▁ . STRNEWLINE TABSYMBOL " greater than or equal to K are " ( strlen ( $ str ) - $ count ) ) ; ? >