Skip to content

Instantly share code, notes, and snippets.

@kingcoyote
Created August 16, 2012 17:49
Show Gist options
  • Save kingcoyote/3372058 to your computer and use it in GitHub Desktop.
Save kingcoyote/3372058 to your computer and use it in GitHub Desktop.
<?php
function unchunk($result) {
return preg_replace_callback(
'/(?:(?:\r\n|\n)|^)([0-9A-F]+)(?:\r\n|\n){1,2}(.*?)'
.'((?:\r\n|\n)(?:[0-9A-F]+(?:\r\n|\n))|$)/si',
create_function(
'$matches',
'return hexdec($matches[1]) == strlen($matches[2]) ?
$matches[2] :
$matches[0];'
),
$result
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment