3v4l.org

run code in 300+ PHP versions simultaneously
<?php function _hex2bin($hex) { $hex = strtoupper($hex); $hexLen = strlen($hex); $bin = []; for ($i = 0; $i < $hexLen; $i++) { $char = $hex[$i]; $bin[] = str_pad(base_convert($char, 16, 2), 4, '0', STR_PAD_LEFT); } return implode("", $bin); } echo _hex2bin("152F302436152F302435152F302434152F302433152F302433");

preferences:
60.4 ms | 402 KiB | 5 Q