note 107645 deleted from function.hex2bin by danbrown
| From: | danbrown@php.net | Date: | Thu, 10 May 2012 20:25:55 +0000 |
| Subject: | note 107645 deleted from function.hex2bin by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-187803@lists.php.net to get a copy of this message | ||
Note Submitter: azizsaleh at gmail dot com
----
Here is the alternative version:
if(!function_exists('hex2bin'))
/**
* Converts the hex representation of data to binary
*
* http://www.php.net/manual/en/function.hex2bin.php
*
* @param string $str Hexadecimal representation of data
*
* @return string Returns the binary representation of the given data
*/
public function hex2bin($data)
{
$bin = "";
$i = 0;
do {
$bin .= chr(hexdec($data{$i}.$data{($i + 1)}));
$i += 2;
} while ($i < strlen($data));
return $bin;
}
}