Home > Article > Backend Development > How to convert letters to decimal numbers in php
In PHP, you can use the ord() function to convert letters into decimal numbers. This function can return the ASCII value of a single character, or the ASCII value of the first character in a string. The syntax is " ord("specified letter")".
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
In php, you can use ord () function to convert letters into decimal numbers.
Example:
<?php echo ord("a")."<br>"; echo ord("b")."<br>"; echo ord("c")."<br>"; echo ord("d")."<br>"; echo ord("A")."<br>"; echo ord("B")."<br>"; echo ord("C")."<br>"; echo ord("D")."<br>"; ?>
Explanation:
ord() function can return The ASCII value of a single character, or the ASCII value of the first character in a string.
Syntax:
ord(string)
Parameters | Description |
---|---|
string | Required. The string from which to obtain the ASCII value. |
Return value: Returns the ASCII value in integer form.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to convert letters to decimal numbers in php. For more information, please follow other related articles on the PHP Chinese website!