Average of ASCII values of characters of a given string | Function to find average of ASCII value of chars ; loop to sum the ascii value of chars ; Returning average of chars ; Driver code
< ? php function averageValue ( $ s ) { $ sum_char = 0 ; for ( $ i = 0 ; $ i < strlen ( $ s ) ; $ i ++ ) { $ sum_char += ord ( $ s [ $ i ] ) ; } return ( int ) ( $ sum_char / strlen ( $ s ) ) ; } $ s = " GeeksforGeeks " ; echo averageValue ( $ s ) ; ? >