3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function createStringFromMap($map) { $chars = array('C*'); end($map); $last = key($map); for ($i = $j = $char = 0; $i <= $last; $i++) { $bit = isset($map[$i]) ? $map[$i] : 0; $char |= ($map[$i] << (7 - $j)); if (++$j === 8) { $chars[] = $char; $j = $char = 0; } } return call_user_func_array('pack', $chars); } $map = array(); $map[1] = 1; $map[9] = 1; $map[17] = 1; $map[25] = 1; echo createStringFromMap($map);
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
Notice: Undefined offset: 0 in /in/iEi1H on line 9 Notice: Undefined offset: 2 in /in/iEi1H on line 9 Notice: Undefined offset: 3 in /in/iEi1H on line 9 Notice: Undefined offset: 4 in /in/iEi1H on line 9 Notice: Undefined offset: 5 in /in/iEi1H on line 9 Notice: Undefined offset: 6 in /in/iEi1H on line 9 Notice: Undefined offset: 7 in /in/iEi1H on line 9 Notice: Undefined offset: 8 in /in/iEi1H on line 9 Notice: Undefined offset: 10 in /in/iEi1H on line 9 Notice: Undefined offset: 11 in /in/iEi1H on line 9 Notice: Undefined offset: 12 in /in/iEi1H on line 9 Notice: Undefined offset: 13 in /in/iEi1H on line 9 Notice: Undefined offset: 14 in /in/iEi1H on line 9 Notice: Undefined offset: 15 in /in/iEi1H on line 9 Notice: Undefined offset: 16 in /in/iEi1H on line 9 Notice: Undefined offset: 18 in /in/iEi1H on line 9 Notice: Undefined offset: 19 in /in/iEi1H on line 9 Notice: Undefined offset: 20 in /in/iEi1H on line 9 Notice: Undefined offset: 21 in /in/iEi1H on line 9 Notice: Undefined offset: 22 in /in/iEi1H on line 9 Notice: Undefined offset: 23 in /in/iEi1H on line 9 Notice: Undefined offset: 24 in /in/iEi1H on line 9 @@@
Output for hhvm-3.10.0 - 3.12.0
Notice: Undefined index: 0 in /in/iEi1H on line 9 Notice: Undefined index: 2 in /in/iEi1H on line 9 Notice: Undefined index: 3 in /in/iEi1H on line 9 Notice: Undefined index: 4 in /in/iEi1H on line 9 Notice: Undefined index: 5 in /in/iEi1H on line 9 Notice: Undefined index: 6 in /in/iEi1H on line 9 Notice: Undefined index: 7 in /in/iEi1H on line 9 Notice: Undefined index: 8 in /in/iEi1H on line 9 Notice: Undefined index: 10 in /in/iEi1H on line 9 Notice: Undefined index: 11 in /in/iEi1H on line 9 Notice: Undefined index: 12 in /in/iEi1H on line 9 Notice: Undefined index: 13 in /in/iEi1H on line 9 Notice: Undefined index: 14 in /in/iEi1H on line 9 Notice: Undefined index: 15 in /in/iEi1H on line 9 Notice: Undefined index: 16 in /in/iEi1H on line 9 Notice: Undefined index: 18 in /in/iEi1H on line 9 @@@
Output for 4.3.0 - 5.2.17
Notice: Undefined offset: 0 in /in/iEi1H on line 9 Notice: Undefined offset: 2 in /in/iEi1H on line 9 Notice: Undefined offset: 3 in /in/iEi1H on line 9 Notice: Undefined offset: 4 in /in/iEi1H on line 9 Notice: Undefined offset: 5 in /in/iEi1H on line 9 Notice: Undefined offset: 6 in /in/iEi1H on line 9 Notice: Undefined offset: 7 in /in/iEi1H on line 9 Notice: Undefined offset: 8 in /in/iEi1H on line 9 Notice: Undefined offset: 10 in /in/iEi1H on line 9 Notice: Undefined offset: 11 in /in/iEi1H on line 9 Notice: Undefined offset: 12 in /in/iEi1H on line 9 Notice: Undefined offset: 13 in /in/iEi1H on line 9 Notice: Undefined offset: 14 in /in/iEi1H on line 9 Notice: Undefined offset: 15 in /in/iEi1H on line 9 Notice: Undefined offset: 16 in /in/iEi1H on line 9 Notice: Undefined offset: 18 in /in/iEi1H on line 9 Notice: Undefined offset: 19 in /in/iEi1H on line 9 Notice: Undefined offset: 20 in /in/iEi1H on line 9 Notice: Undefined offset: 21 in /in/iEi1H on line 9 Notice: Undefined offset: 22 in /in/iEi1H on line 9 Notice: Undefined offset: 23 in /in/iEi1H on line 9 Notice: Undefined offset: 24 in /in/iEi1H on line 9 @@@