PHP 中文轉換爲 二進制 十進制 十六進制,並把十六進制轉換爲中文,

/**
 bindec這個是是把二進制轉換爲十進制
 dechex 十進制轉換爲十六進制
 decbin 十進制轉換爲二進制
 ord 返回ASSIN碼的返回十進制
***/
$hexs = str_split("任");  //若是是中文啊,他是按字節截取  3個字節  截取爲3個元素
$hex= array_map('ord',$hexs);  //把二機制轉化爲十進制
$hex  = array_map('decbin',$hex); //十進制轉換二進制   3個字節 一個字節8 位  24位
$hex   = array_map('bindec',$hex); //二進制轉換爲10進制
$hex   = array_map('dechex',$hex);  //是十進制轉換爲16進制
$hex= join('%',$hex);  //二進制
$hex = '%'.$hex;  //解碼成功 %e5%a6%b
echo urldecode($hex);