3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $show = array( 'mon' => false, 'tue' => false, 'wed' => false, 'thu' => false, 'fri' => false, 'sat' => false, 'sun' => false ); $key = array_keys($show); foreach (range(0,6) as $index) { $key = $keys[$index]; $show[$index] |= true; // in your case |= isset($post[$index]); } var_dump($show);
based on C8t2B
Output for 5.3.0 - 7.2.0
Notice: Undefined variable: keys in /in/VG90j on line 16 Notice: Undefined offset: 0 in /in/VG90j on line 17 Notice: Undefined variable: keys in /in/VG90j on line 16 Notice: Undefined offset: 1 in /in/VG90j on line 17 Notice: Undefined variable: keys in /in/VG90j on line 16 Notice: Undefined offset: 2 in /in/VG90j on line 17 Notice: Undefined variable: keys in /in/VG90j on line 16 Notice: Undefined offset: 3 in /in/VG90j on line 17 Notice: Undefined variable: keys in /in/VG90j on line 16 Notice: Undefined offset: 4 in /in/VG90j on line 17 Notice: Undefined variable: keys in /in/VG90j on line 16 Notice: Undefined offset: 5 in /in/VG90j on line 17 Notice: Undefined variable: keys in /in/VG90j on line 16 Notice: Undefined offset: 6 in /in/VG90j on line 17 array(14) { ["mon"]=> bool(false) ["tue"]=> bool(false) ["wed"]=> bool(false) ["thu"]=> bool(false) ["fri"]=> bool(false) ["sat"]=> bool(false) ["sun"]=> bool(false) [0]=> int(1) [1]=> int(1) [2]=> int(1) [3]=> int(1) [4]=> int(1) [5]=> int(1) [6]=> int(1) }
Output for 5.0.4 - 5.2.17
Notice: Undefined variable: keys in /in/VG90j on line 16 Notice: Undefined offset: 0 in /in/VG90j on line 17 Notice: Undefined variable: keys in /in/VG90j on line 16 Notice: Undefined offset: 1 in /in/VG90j on line 17 Notice: Undefined variable: keys in /in/VG90j on line 16 Notice: Undefined offset: 2 in /in/VG90j on line 17 Notice: Undefined variable: keys in /in/VG90j on line 16 Notice: Undefined offset: 3 in /in/VG90j on line 17 Notice: Undefined variable: keys in /in/VG90j on line 16 Notice: Undefined offset: 4 in /in/VG90j on line 17 Notice: Undefined variable: keys in /in/VG90j on line 16 Notice: Undefined offset: 5 in /in/VG90j on line 17 Notice: Undefined variable: keys in /in/VG90j on line 16 Notice: Undefined offset: 6 in /in/VG90j on line 17 array(14) { ["mon"]=> bool(false) ["tue"]=> bool(false) ["wed"]=> bool(false) ["thu"]=> bool(false) ["fri"]=> bool(false) ["sat"]=> bool(false) ["sun"]=> bool(false) [0]=> int(1) [1]=> int(1) [2]=> int(1) [3]=> int(1) [4]=> int(1) [5]=> int(1) [6]=> int(1) }
Output for 4.3.0 - 5.0.3
Notice: Undefined variable: keys in /in/VG90j on line 16 Notice: Undefined offset: 0 in /in/VG90j on line 17 Notice: Undefined variable: keys in /in/VG90j on line 16 Notice: Undefined offset: 1 in /in/VG90j on line 17 Notice: Undefined variable: keys in /in/VG90j on line 16 Notice: Undefined offset: 2 in /in/VG90j on line 17 Notice: Undefined variable: keys in /in/VG90j on line 16 Notice: Undefined offset: 3 in /in/VG90j on line 17 Notice: Undefined variable: keys in /in/VG90j on line 16 Notice: Undefined offset: 4 in /in/VG90j on line 17 Notice: Undefined variable: keys in /in/VG90j on line 16 Notice: Undefined offset: 5 in /in/VG90j on line 17 Notice: Undefined variable: keys in /in/VG90j on line 16 Notice: Undefined offset: 6 in /in/VG90j on line 17 array(14) { ["mon"]=> bool(false) ["tue"]=> bool(false) ["wed"]=> bool(false) ["thu"]=> bool(false) ["fri"]=> bool(false) ["sat"]=> bool(false) ["sun"]=> bool(false) [0]=> int(1) [1]=> int(1) [2]=> int(1) [3]=> int(1) [4]=> int(1) [5]=> int(1) [6]=> int(1) }