note 41753 added to function.dechex
| From: | admin at rn2 dot php dot net | Date: | Wed, 21 Apr 2004 16:01:18 +0000 |
| Subject: | note 41753 added to function.dechex | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-68456@lists.php.net to get a copy of this message | ||
<?php
/*
here are two functions, some might find them useful (maybe for encoding)
converting string to hex and hex to string:
*/
function strhex($string)
{
$hex="";
for ($i=0;$i<strlen($string);$i++)
$hex.=(strlen(dechex(ord($string[$i])))<2)? "0".dechex(ord($string[$i])):
dechex(ord($string[$i]));
return $hex;
}
function hexstr($hex)
{
$string="";
for ($i=0;$i<strlen($hex)-1;$i+=2)
$string.=chr(hexdec($hex[$i].$hex[$i+1]));
return $string;
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.dechex.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+41753
Delete -- http://master.php.net/manage/user-notes.php?action=delete+41753&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+41753&report=yes
Search -- http://master.php.net/manage/user-notes.php