Home > Backend Development > PHP Problem > How to convert letters to decimal numbers in php

How to convert letters to decimal numbers in php

青灯夜游
Release: 2023-03-15 06:08:02
Original
3088 people have browsed it

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")".

How to convert letters to decimal numbers in php

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>";
?>
Copy after login

How to convert letters to decimal numbers in php

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)
Copy after login
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!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template