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

PHP的16进制互转

PHP中文网
Release: 2016-05-25 17:14:49
Original
1723 people have browsed it


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

                   

Related labels:
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
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template