Converting Character to ASCII Value in PHP

Q

How To Convert a Character to an ASCII Value?

✍: 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

 

PHP Built-in Functions for Strings

⇒⇒PHP Tutorials

2016-10-13, 203👍, 0💬