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

How to convert byte array to hexadecimal in php

藏色散人
藏色散人Original
2022-01-04 10:53:003476browse

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);

Then turn it into a string:

$bin = join($chars);

Finally convert it into a hexadecimal string:

$hex = bin2hex($bin);

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!

Statement:
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