3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $val = 12; $bin_val = 1 << ($val -1); var_dump($bin_val); var_dump(pow(2, $val - 1)); $val = 1 >> ($val - 1); var_dump($val); $binary_string = decbin($bin_val ); // This command test the string with binary values, returning an array with the positions where we have '1'. $positions = StringHelper::strPosAll(strrev($binary_string), '1'); if (is_array($positions)) { // We have to add 1 position to fix the "starts with 0 of arrays". foreach ($positions as $key => $value) { $positions[$key] = ($value + 1); } } else { $positions = array(); } var_dump($positions);
based on J855g
Output for 7.0.0 - 7.1.0
int(2048) int(2048) int(0) Fatal error: Uncaught Error: Class 'StringHelper' not found in /in/OqBDj:19 Stack trace: #0 {main} thrown in /in/OqBDj on line 19
Process exited with code 255.
Output for 5.0.0 - 5.6.28
int(2048) int(2048) int(0) Fatal error: Class 'StringHelper' not found in /in/OqBDj on line 19
Process exited with code 255.
Output for 4.3.2 - 4.4.9
int(2048) int(2048) int(0) Fatal error: Undefined class name 'stringhelper' in /in/OqBDj on line 19
Process exited with code 255.
Output for 4.3.0 - 4.3.1
int(2048) int(2048) int(0) Fatal error: Undefined class name 'stringhelper' in /in/OqBDj on line 19