Home >php教程 >PHP源码 >PHP的16进制互转

PHP的16进制互转

PHP中文网
PHP中文网Original
2016-05-25 17:14:491695browse


<?php
/**
*
* ASCII 转 十六进制 以及 十六进制 转 ASCII
* 非盈利组织或个人请放心转载,商业用途请征得作者同意
*
*/
//ASCII 转 十六进制
function asc2hex($str) {
return &#39;\x&#39;.substr(chunk_split(bin2hex($str), 2, &#39;\x&#39;),0,-2);
}
//十六进制 转 ASCII
function hex2asc($str) {
$str = join(&#39;&#39;,explode(&#39;\x&#39;,$str));
$len = strlen($str);
for ($i=0;$i

                   

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