PHP - String ord() Function
The PHP String ord() function returns the ASCII value of the first character of the specified string.
Syntax
ord(string)
Parameters
string |
Required. Specify the string to get the ASCII value of first character of the string. |
Return Value
Returns the ASCII value of the first character of the specified string.
Example:
In the below example, ord() function returns the ASCII value of the first character of the string called MyString.
<?php $MyString = "Apple"; echo ord($MyString)."\n"; ?>
The output of the above code will be:
65
❮ PHP String functions