chr

string chr(int ascii_code) 

Gets the character for a given ASCII code.

Returns:

ASCII character; NULL if the given integer is not a valid ASCII code

Description:

chr() returns the character associated with the supplied ASCII code. If the integer provided is not a valid ASCII code, the function returns nothing.

Note that the integer can be specified in octal or hex values, as well as decimal. Octal values are denoted by a leading 0 (07, 012, ...), while hex values are denoted by a leading 0x (0xFF, 0x9D, ...).

Version:

PHP 3+, PHP 4+

See also:

Other functions that deal with the ASCII value of a character:

bin2hex() 
ord() 
pack() 
printf() 
sprintf() 
unpack() 

Examples:

Add a null byte to the end of a string
$string .= chr (0); 
Find the ...

Get PHP Functions Essential Reference 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.