3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $integer = 0b100101; $binary = decbin($integer); $binaries = str_split($binary, 1); $binaries = array_reverse($binaries); for ($index = 0; $index < count($binaries); $index++) { $current = &$binaries[$index]; $current = str_pad("", ((count($binaries) - 1) - $index), "0") . $current . str_pad("", $index, "0"); $current = bindec($current); if (empty($current)) { //unset($binaries[$index]); } } $binaries = array_values($binaries); var_dump($binaries);
based on oYmTu
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0, 7.1.0 - 7.3.0alpha1
array(6) { [0]=> int(1) [1]=> int(0) [2]=> int(4) [3]=> int(0) [4]=> int(0) [5]=> &int(32) }