How To Convert a Character to an ASCII Value

Q

How To Convert a Character to an ASCII Value? - PHP Script Tips - PHP Built-in Functions for Strings

✍: FYIcenter.com

A

If you want to convert characters to ASCII values, you can use the ord() function, which takes the first charcter of the specified string, and returns its ASCII value in decimal format. ord() complements chr(). Here is a PHP script on how to use ord():

<?php 
print(ord("Hello")."\n");
print(chr(72)."\n");
?>

This script will print:

72
H

2007-04-21, 5089👍, 0💬