
04.10.2009, 23:21
|
|
Участник форума
Регистрация: 16.09.2006
Сообщений: 139
С нами:
10342455
Репутация:
144
|
|
Код:
<?php
/*
Function: hexToAscii
Code URI: http://ifelse.co.uk/code/hex_to_ascii.php
Description: Nice and simple script that converts a delimited hex string to it's ASCII representation.
Example usage: hexToAscii("4d 49 43 52 4f 50 52 4f 47 52 41 4d 4d 45 52");
Author: Phu Ly
Author URI: http://www.ifelse.co.uk
*/
function hexToAscii($hex, $delimeter=" ")
{
//Remove delimiters from hex string
$hex = str_replace($delimeter, "", $hex);
$strLength = strlen($hex);
$returnVal = '';
for($i=0; $i<$strLength; $i += 2)
{
$dec_val = hexdec(substr($hex, $i, 2));
$returnVal .= chr($dec_val);
}
return $returnVal;
}
?>
|
|
|