Php ord
From w3cyberlearnings
Contents |
PHP function ord
This function returns ASCII value of a character.
Syntax ord
- character: a single character input
ord(character);
Example 1
<?php echo ord('a'); ?>
Output
ASCII value for character 'a' is 97
97
Example 2
<?php $str = 'ABCGORILF'; for ($i = 0; $i < strlen($str); $i++) { echo $str[$i] . ' ASCII value : ' . ord($str[$i]) . '<br/>'; } ?>
Output
A ASCII value: 65 B ASCII value: 66 C ASCII value: 67 G ASCII value: 71 O ASCII value: 79 R ASCII value: 82 I ASCII value: 73 L ASCII value: 76 F ASCII value: 70