3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $times = ['Porto', 'Benfica', 'Maritimo', 'Sporting']; foreach($times as $m => $mandante) { foreach($times as $v => $visitante) { if ($times[$m] != $times[$v]) { $partidas[] = array($times[$m], $times[$v]); } } } $primeiro_turno = null; foreach ($partidas as $p => $partida) { if ($primeiro_turno == null || array_reverse($primeiro_turno[$p]) != $partida) { $primeiro_turno[] = $partida; } else { $segundo_turno[] = $partida; } } print var_dump($partidas); print 'PRIMEIRO TURNO'; print var_dump($primeiro_turno); print 'SEGUNDO TURNO'; print var_dump($segundo_turno);
Output for 5.4.0 - 5.6.28, 7.0.0 - 7.1.0
Notice: Undefined offset: 1 in /in/uN6pf on line 13 Warning: array_reverse() expects parameter 1 to be array, null given in /in/uN6pf on line 13 Notice: Undefined offset: 2 in /in/uN6pf on line 13 Warning: array_reverse() expects parameter 1 to be array, null given in /in/uN6pf on line 13 Notice: Undefined offset: 3 in /in/uN6pf on line 13 Warning: array_reverse() expects parameter 1 to be array, null given in /in/uN6pf on line 13 Notice: Undefined offset: 4 in /in/uN6pf on line 13 Warning: array_reverse() expects parameter 1 to be array, null given in /in/uN6pf on line 13 Notice: Undefined offset: 5 in /in/uN6pf on line 13 Warning: array_reverse() expects parameter 1 to be array, null given in /in/uN6pf on line 13 Notice: Undefined offset: 6 in /in/uN6pf on line 13 Warning: array_reverse() expects parameter 1 to be array, null given in /in/uN6pf on line 13 Notice: Undefined offset: 7 in /in/uN6pf on line 13 Warning: array_reverse() expects parameter 1 to be array, null given in /in/uN6pf on line 13 Notice: Undefined offset: 8 in /in/uN6pf on line 13 Warning: array_reverse() expects parameter 1 to be array, null given in /in/uN6pf on line 13 Notice: Undefined offset: 9 in /in/uN6pf on line 13 Warning: array_reverse() expects parameter 1 to be array, null given in /in/uN6pf on line 13 Notice: Undefined offset: 10 in /in/uN6pf on line 13 Warning: array_reverse() expects parameter 1 to be array, null given in /in/uN6pf on line 13 Notice: Undefined offset: 11 in /in/uN6pf on line 13 Warning: array_reverse() expects parameter 1 to be array, null given in /in/uN6pf on line 13 array(12) { [0]=> array(2) { [0]=> string(5) "Porto" [1]=> string(7) "Benfica" } [1]=> array(2) { [0]=> string(5) "Porto" [1]=> string(8) "Maritimo" } [2]=> array(2) { [0]=> string(5) "Porto" [1]=> string(8) "Sporting" } [3]=> array(2) { [0]=> string(7) "Benfica" [1]=> string(5) "Porto" } [4]=> array(2) { [0]=> string(7) "Benfica" [1]=> string(8) "Maritimo" } [5]=> array(2) { [0]=> string(7) "Benfica" [1]=> string(8) "Sporting" } [6]=> array(2) { [0]=> string(8) "Maritimo" [1]=> string(5) "Porto" } [7]=> array(2) { [0]=> string(8) "Maritimo" [1]=> string(7) "Benfica" } [8]=> array(2) { [0]=> string(8) "Maritimo" [1]=> string(8) "Sporting" } [9]=> array(2) { [0]=> string(8) "Sporting" [1]=> string(5) "Porto" } [10]=> array(2) { [0]=> string(8) "Sporting" [1]=> string(7) "Benfica" } [11]=> array(2) { [0]=> string(8) "Sporting" [1]=> string(8) "Maritimo" } } PRIMEIRO TURNOarray(12) { [0]=> array(2) { [0]=> string(5) "Porto" [1]=> string(7) "Benfica" } [1]=> array(2) { [0]=> string(5) "Porto" [1]=> string(8) "Maritimo" } [2]=> array(2) { [0]=> string(5) "Porto" [1]=> string(8) "Sporting" } [3]=> array(2) { [0]=> string(7) "Benfica" [1]=> string(5) "Porto" } [4]=> array(2) { [0]=> string(7) "Benfica" [1]=> string(8) "Maritimo" } [5]=> array(2) { [0]=> string(7) "Benfica" [1]=> string(8) "Sporting" } [6]=> array(2) { [0]=> string(8) "Maritimo" [1]=> string(5) "Porto" } [7]=> array(2) { [0]=> string(8) "Maritimo" [1]=> string(7) "Benfica" } [8]=> array(2) { [0]=> string(8) "Maritimo" [1]=> string(8) "Sporting" } [9]=> array(2) { [0]=> string(8) "Sporting" [1]=> string(5) "Porto" } [10]=> array(2) { [0]=> string(8) "Sporting" [1]=> string(7) "Benfica" } [11]=> array(2) { [0]=> string(8) "Sporting" [1]=> string(8) "Maritimo" } } SEGUNDO TURNO Notice: Undefined variable: segundo_turno in /in/uN6pf on line 23 NULL
Output for hhvm-3.10.0 - 3.12.0
Notice: Undefined index: 1 in /in/uN6pf on line 13 Warning: array_reverse() expects parameter 1 to be array, null given in /in/uN6pf on line 13 Notice: Undefined index: 2 in /in/uN6pf on line 13 Warning: array_reverse() expects parameter 1 to be array, null given in /in/uN6pf on line 13 Notice: Undefined index: 3 in /in/uN6pf on line 13 Warning: array_reverse() expects parameter 1 to be array, null given in /in/uN6pf on line 13 Notice: Undefined index: 4 in /in/uN6pf on line 13 Warning: array_reverse() expects parameter 1 to be array, null given in /in/uN6pf on line 13 Notice: Undefined index: 5 in /in/uN6pf on line 13 Warning: array_reverse() expects parameter 1 to be array, null given in /in/uN6pf on line 13 Notice: Undefined index: 6 in /in/uN6pf on line 13 Warning: array_reverse() expects parameter 1 to be array, null given in /in/uN6pf on line 13 Notice: Undefined index: 7 in /in/uN6pf on line 13 Warning: array_reverse() expects parameter 1 to be array, null given in /in/uN6pf on line 13 Notice: Undefined index: 8 in /in/uN6pf on line 13 Warning: array_reverse() expects parameter 1 to be array, null given in /in/uN6pf on line 13 array(12) { [0]=> array(2) { [0]=> string(5) "Porto" [1]=> string(7) "Benfica" } [1]=> array(2) { [0]=> string(5) "Porto" [1]=> string(8) "Maritimo" } [2]=> array(2) { [0]=> string(5) "Porto" [1]=> string(8) "Sporting" } [3]=> array(2) { [0]=> string(7) "Benfica" [1]=> string(5) "Porto" } [4]=> array(2) { [0]=> string(7) "Benfica" [1]=> string(8) "Maritimo" } [5]=> array(2) { [0]=> string(7) "Benfica" [1]=> string(8) "Sporting" } [6]=> array(2) { [0]=> string(8) "Maritimo" [1]=> string(5) "Porto" } [7]=> array(2) { [0]=> string(8) "Maritimo" [1]=> string(7) "Benfica" } [8]=> array(2) { [0]=> string(8) "Maritimo" [1]=> string(8) "Sporting" } [9]=> array(2) { [0]=> string(8) "Sporting" [1]=> string(5) "Porto" } [10]=> array(2) { [0]=> string(8) "Sporting" [1]=> string(7) "Benfica" } [11]=> array(2) { [0]=> string(8) "Sporting" [1]=> string(8) "Maritimo" } } PRIMEIRO TURNOarray(12) { [0]=> array(2) { [0]=> string(5) "Porto" [1]=> string(7) "Benfica" } [1]=> array(2) { [0]=> string(5) "Porto" [1]=> string(8) "Maritimo" } [2]=> array(2) { [0]=> string(5) "Porto" [1]=> string(8) "Sporting" } [3]=> array(2) { [0]=> string(7) "Benfica" [1]=> string(5) "Porto" } [4]=> array(2) { [0]=> string(7) "Benfica" [1]=> string(8) "Maritimo" } [5]=> array(2) { [0]=> string(7) "Benfica" [1]=> string(8) "Sporting" } [6]=> array(2) { [0]=> string(8) "Maritimo" [1]=> string(5) "Porto" } [7]=> array(2) { [0]=> string(8) "Maritimo" [1]=> string(7) "Benfica" } [8]=> array(2) { [0]=> string(8) "Maritimo" [1]=> string(8) "Sporting" } [9]=> array(2) { [0]=> string(8) "Sporting" [1]=> string(5) "Porto" } [10]=> array(2) { [0]=> string(8) "Sporting" [1]=> string(7) "Benfica" } [11]=> array(2) { [0]=> string(8) "Sporting" [1]=> string(8) "Maritimo" } } SEGUNDO TURNONULL
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/uN6pf on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/uN6pf on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/uN6pf on line 3
Process exited with code 255.