Name
chr()
Synopsis
string chr ( int ascii_val
)
To convert an ASCII number to its character equivalent, use the chr()
function. This takes an ASCII value as its parameter and returns the character equivalent, if there is one.
$letter = chr(109); print "ASCII number 109 is equivalent to $letter\n";
That would output "ASCII number 109 is equivalent to m"
. The ord()
function does the opposite of chr()
: it takes a string and returns the equivalent ASCII value.
Get PHP in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.