- print_r: documentation ( source)
- strtoupper: documentation ( source)
- str_split: documentation ( source)
- ord: documentation ( source)
<?php
$key = "66b3b0d86b56dfca4c8ca3e883700ac6";
$key = str2hex_array($key);
print_r($key);
function str2hex_array($str){
$str_arr = str_split(strToUpper($str), 2);
//$str_hex = array();
$str_hex = "";
for ($i=0; $i < count($str_arr); $i++){
$ord1 = ord($str_arr[$i][0])-48;
$ord2 = ord($str_arr[$i][1])-48;
if ($ord1 > 16) $ord1 = $ord1 - 7;
if ($ord2 > 16) $ord2 = $ord2 - 7;
$str_hex[$i] = $ord1 * 16 + $ord2;
}
return $str_hex;
}