What is the function in PHP to convert a letter to its corresponding ASCII code and vice versa?

To convert a letter to its corresponding ASCII code in PHP, you can use the ord() function. This function takes a single character as input and returns the ASCII value of that character. To convert an ASCII code back to its corresponding letter, you can use the chr() function. This function takes an ASCII value as input and returns the corresponding character.

// Convert a letter to its corresponding ASCII code
$letter = 'A';
$asciiCode = ord($letter);
echo "The ASCII code of $letter is $asciiCode";

// Convert an ASCII code to its corresponding letter
$asciiCode = 65;
$letter = chr($asciiCode);
echo "The letter corresponding to ASCII code $asciiCode is $letter";