Skip to content

Instantly share code, notes, and snippets.

@gregmercer
Created October 10, 2013 15:34
Show Gist options
  • Select an option

  • Save gregmercer/6920405 to your computer and use it in GitHub Desktop.

Select an option

Save gregmercer/6920405 to your computer and use it in GitHub Desktop.
php string to hex function
function strtohex($string)
{
$string = str_split($string);
foreach($string as &$char)
$char = "\x".dechex(ord($char));
return implode('',$string);
}
@xwiz
Copy link
Copy Markdown

xwiz commented Oct 16, 2018

Why not just bin2hex?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment