3v4l.org

run code in 300+ PHP versions simultaneously
<?php function pack_array_of_bools_to_string(array $bools): string { $str = ''; $l = count($bools); for ($i = 0; $i < $l; ++$i) { $str .= $bools ? '1' : '0'; } return $str; } function unpack_string_to_array_of_bools(string $packed): array { $arr = []; $l = strlen($packed) - 1; for ($i = 0; $i < $l; ++$i) { $arr[] = $packed[$i] === '1'; } return $arr; } $arr = [ true, true, false, true, false, false, true, true, false, false, false, true, false ]; var_dump( pack_array_of_bools_to_string($arr), unpack_string_to_array_of_bools('1101001100010') );
Output for git.master, git.master_jit, rfc.property-hooks
string(13) "1111111111111" array(12) { [0]=> bool(true) [1]=> bool(true) [2]=> bool(false) [3]=> bool(true) [4]=> bool(false) [5]=> bool(false) [6]=> bool(true) [7]=> bool(true) [8]=> bool(false) [9]=> bool(false) [10]=> bool(false) [11]=> bool(true) }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
65.31 ms | 401 KiB | 8 Q