To convert an ASCII number to its character equivalent, use the chr()
function.
chr()
takes an ASCII value and returns the character equivalent, if there is one.
chr()
has the following format.
PHP chr() Function has the following syntax.
string chr ( int ascii_val )
ascii_val
is the value to convert.
PHP chr() function returns character from ascii number.
The ord()
function does the opposite of chr()
:
it takes a string and returns the equivalent ASCII value.
Convert number to character
<?PHP
$letter = chr(100);
print "ASCII number 100 is equivalent to $letter\n";
?>
The code above generates the following result.