3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $rows[10] = array('01','8:50','I','CASA','1'); $rows[9] = array('01','8:50','I','CASA','0'); $rows[8] = array('01','8:30','I','CASA','0'); $rows[7] = array('01','8:50','I','CASA','1'); $rows[6] = array('01','8:50','I','CASA','0'); $rows[5] = array('01','8:00','I','CASA','0'); $rows[4] = array('01','7:50','I','CASA','1'); $rows[3] = array('01','7:50','I','CASA','0'); $rows[2] = array('01','7:45','I','CASA','0'); $rows[1] = array('01','7:30','I','CASA','0'); echo "originale<br>"; foreach ($rows as $k => $v) { echo "$k) "; foreach($v as $kk => $vv) { echo $vv ." | "; } echo "<br>"; } foreach ($rows as $k => $v) { if($v[4] == 1) { $keys_to_remove[] = $k-1; } } echo "<pre>"; print_r($keys_to_remove); echo "</pre>"; foreach($keys_to_remove as $key){ unset($rows[$key]); } echo "modificato<br>"; foreach ($rows as $k => $v) { echo "$k) "; foreach($v as $kk => $vv) { echo $vv ." | "; } echo "<br>"; }
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
originale<br>10) 01 | 8:50 | I | CASA | 1 | <br>9) 01 | 8:50 | I | CASA | 0 | <br>8) 01 | 8:30 | I | CASA | 0 | <br>7) 01 | 8:50 | I | CASA | 1 | <br>6) 01 | 8:50 | I | CASA | 0 | <br>5) 01 | 8:00 | I | CASA | 0 | <br>4) 01 | 7:50 | I | CASA | 1 | <br>3) 01 | 7:50 | I | CASA | 0 | <br>2) 01 | 7:45 | I | CASA | 0 | <br>1) 01 | 7:30 | I | CASA | 0 | <br><pre>Array ( [0] => 9 [1] => 6 [2] => 3 ) </pre>modificato<br>10) 01 | 8:50 | I | CASA | 1 | <br>8) 01 | 8:30 | I | CASA | 0 | <br>7) 01 | 8:50 | I | CASA | 1 | <br>5) 01 | 8:00 | I | CASA | 0 | <br>4) 01 | 7:50 | I | CASA | 1 | <br>2) 01 | 7:45 | I | CASA | 0 | <br>1) 01 | 7:30 | I | CASA | 0 | <br>