In this tutorial, you shall learn how to get the ASCII value of a character in PHP using ord() function, with example programs.
PHP – Get ASCII Value of a Character
To get the ASCII value of a character in PHP, call
ord() String function and pass the character (as string) as argument to the function.
ord() String function takes string as an argument and returns the first byte of the string as a value between 0 and 255.
1. Get ASCII value of the character “m”
In the following example, we get the ASCII value of character m using
<?php $ch = "m"; $ascii = ord($ch); printf("ASCII : %d", $ascii); ?>
In this PHP Tutorial, we learned how to convert array into a CSV string, using
implode() function, with examples.