Skip to content

Instantly share code, notes, and snippets.

@azcdev
Created October 12, 2013 03:37
Show Gist options
  • Save azcdev/6945514 to your computer and use it in GitHub Desktop.
Save azcdev/6945514 to your computer and use it in GitHub Desktop.
funcion hex2bin introducida en PHP 5.4, pero no disponible en versiones inferiores.
<?php
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment