TOP ▲ itcore TOP プログラムパーツ

u_hex2bin hex2bin() PHP5.4未満 16進エンコードされたバイナリ文字列をデコードする | itcore 2021年

PHP

PHP TOP

関数

<?php
function u_hex2bin($hex_string) {
  $binary_string = pack("H*" , $hex_string);
  return $binary_string;
}
?>

テストプログラム

<?php include_once "u_hex2bin.func"; ?>
<?php
$hex = u_hex2bin("6578616d706c65206865782064617461");
var_dump($hex);
?>

実行結果

string(16) "example hex data"