Home > Backend Development > PHP Problem > How to convert byte array to hexadecimal in php

How to convert byte array to hexadecimal in php

藏色散人
Release: 2023-03-14 17:54:02
Original
3765 people have browsed it

php method to convert byte array to hexadecimal: 1. Convert each integer into a character; 2. Convert to a string through "join($chars);"; 3. Use "bin2hex( $bin);" just convert it into a hexadecimal string.

How to convert byte array to hexadecimal in php

#The operating environment of this article: Windows 7 system, PHP version 7.1, Dell G3 computer.

How to convert byte array to hexadecimal in php?

php - Convert byte array to hexadecimal string

Method:

You can convert each integer first Convert to character.

$chars = array_map("chr", $arr);
Copy after login

Then turn it into a string:

$bin = join($chars);
Copy after login

Finally convert it into a hexadecimal string:

$hex = bin2hex($bin);
Copy after login

Recommended learning: "PHP Video tutorial

The above is the detailed content of How to convert byte array to hexadecimal in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template