note 86752 added to function.bin2hex

From: Date: Sun, 02 Nov 2008 09:19:15 +0000
Subject: note 86752 added to function.bin2hex
Groups: php.notes 
Request: Send a blank email to php-notes+get-146032@lists.php.net to get a copy of this message
Thanks to chaos79 <?php // Convert a hex-string to binary-string (the way back from bin2hex) function hex2bin($h) { if (!is_string($h)) return null; $long=strlen($h); if($long%2 != 0) return null; $r=''; for ($a=0; $a<$long; $a+=2) { $r.=chr(hexdec($h{$a}.$h{($a+1)})); } return $r; } echo bin2hex('Hello'); // result: 48656c6c6f echo hex2bin('48656c6c6f'); // result: Hello ?> ---- Server IP: 80.64.47.13 Probable Submitter: 81.38.216.242 ---- Manual Page -- http://www.php.net/manual/en/function.bin2hex.php Edit -- https://master.php.net/note/edit/86752 Del: integrated -- https://master.php.net/note/delete/86752/integrated Del: useless -- https://master.php.net/note/delete/86752/useless Del: bad code -- https://master.php.net/note/delete/86752/bad+code Del: spam -- https://master.php.net/note/delete/86752/spam Del: non-english -- https://master.php.net/note/delete/86752/non-english Del: in docs -- https://master.php.net/note/delete/86752/in+docs Del: other reasons-- https://master.php.net/note/delete/86752 Reject -- https://master.php.net/note/reject/86752 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#146032) next »