3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $binarydata = "\x32\x42\x00\xa0"; $array = unpack("c2/n", $binarydata); var_dump($array); var_dump($packed = pack('a6', '')); // PHP 5.4 $data = "hoge" // PHP 5.5 $data = "hoge\0\0" var_dump($data = unpack('a6', $packed)); // PHP 5.5 $data = "hoge" var_dump($data = unpack('Z6', $packed));
based on DA2mE
Output for 5.5.24 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(2) { [1]=> int(160) [2]=> int(66) } string(6) "" array(1) { [1]=> string(6) "" } array(1) { [1]=> string(0) "" }
Output for 4.4.8 - 4.4.9, 5.2.4 - 5.4.45
array(2) { [1]=> int(160) [2]=> int(66) } string(6) "" array(1) { [1]=> string(0) "" } Warning: unpack(): Invalid format type Z in /in/PMGX1 on line 14 bool(false)
Output for 4.3.5 - 4.4.7, 5.0.0 - 5.2.3
array(2) { [1]=> int(160) [2]=> int(66) } string(6) "" array(1) { [1]=> string(0) "" } array(0) { }
Output for 4.3.0 - 4.3.4
array(3) { [1]=> int(50) [2]=> int(66) [""]=> int(160) } string(6) "" array(1) { [""]=> string(0) "" } array(0) { }