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 <= $end; $i++) { $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 - 7.1.0
Notice: Undefined variable: end in /in/X0GbB on line 7 Notice: Undefined offset: 0 in /in/X0GbB on line 8 Notice: Undefined variable: end in /in/X0GbB on line 7
Output for 5.0.4 - 5.2.17
Notice: Undefined variable: end in /in/X0GbB on line 7 Notice: Undefined offset: 0 in /in/X0GbB on line 8 Notice: Undefined variable: end in /in/X0GbB on line 7
Output for 4.3.0 - 5.0.3
Notice: Undefined variable: end in /in/X0GbB on line 7 Notice: Undefined offset: 0 in /in/X0GbB on line 8 Notice: Undefined variable: end in /in/X0GbB on line 7