How To Convert a Character to an ASCII Value?

deepak singh
Posts: 686
Joined: Fri Sep 30, 2016 4:19 pm

How To Convert a Character to an ASCII Value?

Postby deepak singh » Sat Oct 01, 2016 4:49 pm

How To Convert a Character to an ASCII Value?

rameshkhd
Posts: 1279
Joined: Sun Aug 28, 2016 10:45 am

Re: How To Convert a Character to an ASCII Value?

Postby rameshkhd » Sat Oct 01, 2016 4:50 pm

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


Return to “PHP”

Who is online

Users browsing this forum: No registered users and 2 guests