php加密解密0x数组

<?php
//加密字符串
$str='hello world';
$arr=str_split($str);
$arr1=array();
foreach($arr as $v){
   $ordv=ord($v);
   $arr1[]='0x'.dechex($ordv);
}
print_r($arr1);  
//输出Array ( [0] => 0x68 [1] => 0x65 [2] => 0x6c [3] => 0x6c [4] => 0x6f [5] => 0x20 [6] => 0x77 [7] => 0x6f [8] => 0x72 [9] => 0x6c [10] => 0x64 )
//解密数组 $statport = array(0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x77,0x77,0x2e,0x64,0x65,0x64,0x65, 0x63,0x6d,0x73,0x2e,0x63,0x6f,0x6d,0x2f,0x73,0x74,0x61,0x74,0x2e,0x70,0x68,0x70, 0x3f,0x72,0x66,0x68,0x6f,0x73,0x74,0x3d); $staturl = ''; foreach($statport as $c) { $staturl .= chr($c); } echo $staturl; //http://www.dedecms.com/stat.php?rfhost= ?>
原文地址:https://www.cnblogs.com/txxt/p/5708125.html