note 86123 added to function.bin2hex

From: Date: Sat, 04 Oct 2008 03:30:59 +0000
Subject: note 86123 added to function.bin2hex
Groups: php.notes 
Request: Send a blank email to php-notes+get-145038@lists.php.net to get a copy of this message
Because the way back (hex2bin) doesn't exist on php, i've written another little function without using commands like pack: <?php // Convert a hex-string to binary-string (the way back from bin2hex) function hex2bin($h) { if (!is_string($h)) return null; $r=''; for ($a=0; $a<strlen($h); $a+=2) { $r.=chr(hexdec($h{$a}.$h{($a+1)})); } return $r; } echo bin2hex('Hello'); // result: 48656c6c6f echo hex2bin('48656c6c6f'); // result: Hello ?> ---- Server IP: 217.13.201.10 Probable Submitter: 89.56.25.218 ---- Manual Page -- http://www.php.net/manual/en/function.bin2hex.php Edit -- https://master.php.net/note/edit/86123 Del: integrated -- https://master.php.net/note/delete/86123/integrated Del: useless -- https://master.php.net/note/delete/86123/useless Del: bad code -- https://master.php.net/note/delete/86123/bad+code Del: spam -- https://master.php.net/note/delete/86123/spam Del: non-english -- https://master.php.net/note/delete/86123/non-english Del: in docs -- https://master.php.net/note/delete/86123/in+docs Del: other reasons-- https://master.php.net/note/delete/86123 Reject -- https://master.php.net/note/reject/86123 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#145038) next »