PHP Questions Home | Register | Login
Categories
Arrays
Files
Forms
Creating PDFs
PHP Errors
Functions
Images
MySQL
Numbers
Others
Strings
Website
Unanswered

PHP Forums
Forums Index
MySQL Forum
PHP Forum
Flash/Actionscript
Javascript
Web design

More PHP
PHP Functions
Top Questions
Ask a Question
PHP Interview Questions
PHP Jobs
Ecommerce
IT Questions
Business Websites

Sponsors

sponsor ad
My Salary
PHP Developer Salary
Advertise Here

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.



Comment on this Question and Answer >>>

ASK A QUESTION

More strings PHP Questions

How do I find the length of a string in PHP?

How do I make the first letter of a string uppercase?

How do I calculate the MD5 hash of a string?

How do I find the position of a letter in a string in PHP?

How do I join strings together?



Custom Search