3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $value = 1023; $value = decbin($value); $value = str_split(strrev($value)); $bitValues = array(); foreach($value as $pos => $bit) { if (0 != $bit) { $bitValues[] = pow(2, $pos); } } var_dump($bitValues);
Output for 5.0.0 - 7.1.0
array(10) { [0]=> int(1) [1]=> int(2) [2]=> int(4) [3]=> int(8) [4]=> int(16) [5]=> int(32) [6]=> int(64) [7]=> int(128) [8]=> int(256) [9]=> int(512) }
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: str_split() in /in/F7XWn on line 7
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: str_split() in /in/F7XWn on line 7
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: str_split() in /in/F7XWn on line 7