3v4l.org

run code in 300+ PHP versions simultaneously
<?php $int = 5; $bits = []; function int_to_bools($int, $count) { $bools = []; for ($i = 0; $i < $count; $i++) { $bools[$i] = (bool)($int & (2 ** $i)); } return $bools; } function bools_to_int($bools) { $int = 0; foreach (array_values($bools) as $i => $bit) { $int |= ((int)$bit) << $i; } return $int; } $int = 5; $bools = int_to_bools($int, 10); var_dump($bools); $int = bools_to_int($bools); var_dump($int);
Output for git.master, git.master_jit, rfc.property-hooks
array(10) { [0]=> bool(true) [1]=> bool(false) [2]=> bool(true) [3]=> bool(false) [4]=> bool(false) [5]=> bool(false) [6]=> bool(false) [7]=> bool(false) [8]=> bool(false) [9]=> bool(false) } int(5)

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:
43.47 ms | 1750 KiB | 4 Q