PHP ord() work: Here, we will find out about the ord() work with Example in PHP.
PHP ord() work
ord() work is a string capacity, it is utilized to get the ASCII code of the main character of the given string.
Syntax:
ord(string);
- It acknowledges the string and returns the number value (ASCII code).
Examples:
Input: "Abc"
Output: 65
PHP Code:
<?php
$str = "Abc";
echo ("ASCII code of first character is = " . ord($str) . "\n");
$str = "Hello world";
echo ("ASCII code of first character is = " . ord($str) . "\n");
$str = "_okay";
echo ("ASCII code of first character is = " . ord($str) . "\n");
$str = "123Hello";
echo ("ASCII code of first character is = " . ord($str) . "\n");
?>
Output
ASCII code of first character is = 65
ASCII code of first character is = 72
ASCII code of first character is = 95
ASCII code of first character is = 49
2 thoughts on “PHP ord() Function with Example”