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') );

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
7.0.10.0070.07020.24
7.0.00.0100.08320.07
5.6.160.0070.04720.50
5.6.150.0070.08318.22
5.6.140.0070.07718.15
5.6.130.0030.04018.18
5.6.120.0030.06320.95
5.6.110.0130.04721.09
5.6.100.0170.07721.02
5.6.90.0070.03720.99
5.6.80.0100.03320.35
5.5.300.0030.04318.07
5.5.290.0130.07317.94
5.5.280.0030.04320.88
5.5.270.0030.05320.77
5.5.260.0130.08020.76
5.5.250.0100.07720.66
5.5.240.0070.03320.07

preferences:
138.87 ms | 1394 KiB | 7 Q