September 2001
Intermediate to advanced
768 pages
32h 45m
English
int ord(string character) Gets the ASCII code for a character.
Returns:
Integer between 0 and 255
Description:
ord() returns the ASCII code for a single character. The value is returned in decimal/base10. To convert the value to hex or octal, use decbin() or dechex(), respectively.
Version:
PHP 3+, PHP 4+
See also:
Other functions that deal with the ASCII value of a character:
bin2hex() chr() pack() printf() sprintf() unpack()
Example:
<?php echo ord ("\n"); ?>
Output:
10
|
Read now
Unlock full access