PHP Questions Home

Categories

Arrays
Files
Forms
Functions
Images
MySQL
Numbers
Others
Strings
Website


PHP Functions

PHP Functions


More PHP

Top Questions
Ask a Question

How do I find the ASCII value of a string character?


Sometimes you will need to know the ASCII value of a character in your string.

If you want to find this for the first character, then PHP offers the very simple function ord, which works a little like this:

<?php
$text 
"\nhello";
echo 
ord($text);
?>


This little example will print '10' and shows one simple way in which this could be a function we want to use - we can use it to check for a leading line feed at the start of the string for instance by seeing if the ord($text) value returns 10.



More strings PHP Questions

How do I calculate the MD5 hash of a string?
How do I reverse a string in PHP?
How do I find the length of a string in PHP?
How do I calculate the metaphone of a string?
How can I remove trailing space from a string?