Home >Backend Development >PHP Problem >How to convert byte array to hexadecimal in php
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.
#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!