note 100578 added to function.hexdec
| From: | andy at haveland dot com | Date: | Mon, 25 Oct 2010 05:55:20 +0000 |
| Subject: | note 100578 added to function.hexdec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-173427@lists.php.net to get a copy of this message | ||
Here's a short example to convert strings between hex and chars:
print hextostr("616E647940686176656C616E642E636F6D")."\n";
print strtohex("Knowledge is power")."\n";
function hextostr($x) {
$s='';
foreach(explode("\n",trim(chunk_split($x,2))) as $h) $s.=chr(hexdec($h));
return($s);
}
function strtohex($x) {
$s='';
foreach(str_split($x) as $c) $s.=sprintf("%02X",ord($c));
return($s);
}
----
Server IP: 69.147.83.197
Probable Submitter: 80.98.113.68
----
Manual Page -- http://www.php.net/manual/en/function.hexdec.php
Edit -- https://master.php.net/note/edit/100578
Del: integrated -- https://master.php.net/note/delete/100578/integrated
Del: useless -- https://master.php.net/note/delete/100578/useless
Del: bad code -- https://master.php.net/note/delete/100578/bad+code
Del: spam -- https://master.php.net/note/delete/100578/spam
Del: non-english -- https://master.php.net/note/delete/100578/non-english
Del: in docs -- https://master.php.net/note/delete/100578/in+docs
Del: other reasons-- https://master.php.net/note/delete/100578
Reject -- https://master.php.net/note/reject/100578
Search -- https://master.php.net/manage/user-notes.php