note 112912 deleted from function.hex2bin by googleguy

From: Date: Tue, 06 Aug 2013 09:06:48 +0000
Subject: note 112912 deleted from function.hex2bin by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-195882@lists.php.net to get a copy of this message
Note Submitter: jannik [dot] zappe [at] udo [dot] edu ---- Since this function only exists from PHP 5.4 and above, the following works as a drop-in replacement for older versions of PHP. It is a little modified version of the code provided by @Johnson. It seems to works pretty fine. <?php if ( !function_exists( 'hex2bin' ) ) { function hex2bin( $str ) { $sbin = ""; $len = strlen( $str ); for ( $i = 0; $i < $len; $i += 2 ) { $sbin .= pack( "H*", substr( $str, $i, 2 ) ); } return $sbin; } } ?>

« previous php.notes (#195882) next »