3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $paths = array( 'one' => array( 'visited' => false, 'shortest_path' => INF, 'neighbors' => array( 'two' => array(1 => bus), 'three' => array(5 => subway), 'fow' => array(10 => bus), ) ), 'two' => array( 'visited' => false, 'shortest_path' => INF, 'neighbors' => array( 'one' => array(1 => bus), ) ), 'three' => array( 'visited' => false, 'shortest_path' => INF, 'neighbors' => array( 'one' => array(5 => bus), 'six' => array(20 => foot) ) ), 'fow' => array( 'visited' => false, 'shortest_path' => INF, 'neighbors' => array( 'one' => array(10 => bus), 'five' => array(5 => bus) ) ), 'five' => array( 'visited' => false, 'shortest_path' => INF, 'neighbors' => array( 'fow' => array(5 => bus), 'six' => array(5 => foot) ) ), 'six' => array( 'visited' => false, 'shortest_path' => INF, 'neighbors' => array( 'three' => array(20 => bus), 'five' => array(5 => foot) ) ) ); $array = array ( 0 => 'two ', 1 => 'three ', 2 => 'fow ', 3 => 'five ', 4 => 'six ', 5 => 'six ', ); // sort ДЛЯ СОРТИРОВКИ foreach ($array as $key => $name) { echo $name."\n"; if (count($paths[$name][neighbors]) >=2 ) { echo 123; foreach ($paths[$name][neighbors] as $neighbor) { if ($array[$key+1] == $neighbor) { echo $name; } } } }
based on n6epa
Output for 7.2.0 - 7.2.6
Warning: Use of undefined constant bus - assumed 'bus' (this will throw an Error in a future version of PHP) in /in/3b26v on line 8 Warning: Use of undefined constant subway - assumed 'subway' (this will throw an Error in a future version of PHP) in /in/3b26v on line 9 Warning: Use of undefined constant bus - assumed 'bus' (this will throw an Error in a future version of PHP) in /in/3b26v on line 10 Warning: Use of undefined constant bus - assumed 'bus' (this will throw an Error in a future version of PHP) in /in/3b26v on line 18 Warning: Use of undefined constant bus - assumed 'bus' (this will throw an Error in a future version of PHP) in /in/3b26v on line 26 Warning: Use of undefined constant foot - assumed 'foot' (this will throw an Error in a future version of PHP) in /in/3b26v on line 27 Warning: Use of undefined constant bus - assumed 'bus' (this will throw an Error in a future version of PHP) in /in/3b26v on line 35 Warning: Use of undefined constant bus - assumed 'bus' (this will throw an Error in a future version of PHP) in /in/3b26v on line 36 Warning: Use of undefined constant bus - assumed 'bus' (this will throw an Error in a future version of PHP) in /in/3b26v on line 44 Warning: Use of undefined constant foot - assumed 'foot' (this will throw an Error in a future version of PHP) in /in/3b26v on line 45 Warning: Use of undefined constant bus - assumed 'bus' (this will throw an Error in a future version of PHP) in /in/3b26v on line 53 Warning: Use of undefined constant foot - assumed 'foot' (this will throw an Error in a future version of PHP) in /in/3b26v on line 54 two Warning: Use of undefined constant neighbors - assumed 'neighbors' (this will throw an Error in a future version of PHP) in /in/3b26v on line 76 Notice: Undefined index: two in /in/3b26v on line 76 Warning: count(): Parameter must be an array or an object that implements Countable in /in/3b26v on line 76 three Warning: Use of undefined constant neighbors - assumed 'neighbors' (this will throw an Error in a future version of PHP) in /in/3b26v on line 76 Notice: Undefined index: three in /in/3b26v on line 76 Warning: count(): Parameter must be an array or an object that implements Countable in /in/3b26v on line 76 fow Warning: Use of undefined constant neighbors - assumed 'neighbors' (this will throw an Error in a future version of PHP) in /in/3b26v on line 76 Notice: Undefined index: fow in /in/3b26v on line 76 Warning: count(): Parameter must be an array or an object that implements Countable in /in/3b26v on line 76 five Warning: Use of undefined constant neighbors - assumed 'neighbors' (this will throw an Error in a future version of PHP) in /in/3b26v on line 76 Notice: Undefined index: five in /in/3b26v on line 76 Warning: count(): Parameter must be an array or an object that implements Countable in /in/3b26v on line 76 six Warning: Use of undefined constant neighbors - assumed 'neighbors' (this will throw an Error in a future version of PHP) in /in/3b26v on line 76 Notice: Undefined index: six in /in/3b26v on line 76 Warning: count(): Parameter must be an array or an object that implements Countable in /in/3b26v on line 76 six Warning: Use of undefined constant neighbors - assumed 'neighbors' (this will throw an Error in a future version of PHP) in /in/3b26v on line 76 Notice: Undefined index: six in /in/3b26v on line 76 Warning: count(): Parameter must be an array or an object that implements Countable in /in/3b26v on line 76
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.1.20
Notice: Use of undefined constant bus - assumed 'bus' in /in/3b26v on line 8 Notice: Use of undefined constant subway - assumed 'subway' in /in/3b26v on line 9 Notice: Use of undefined constant bus - assumed 'bus' in /in/3b26v on line 10 Notice: Use of undefined constant bus - assumed 'bus' in /in/3b26v on line 18 Notice: Use of undefined constant bus - assumed 'bus' in /in/3b26v on line 26 Notice: Use of undefined constant foot - assumed 'foot' in /in/3b26v on line 27 Notice: Use of undefined constant bus - assumed 'bus' in /in/3b26v on line 35 Notice: Use of undefined constant bus - assumed 'bus' in /in/3b26v on line 36 Notice: Use of undefined constant bus - assumed 'bus' in /in/3b26v on line 44 Notice: Use of undefined constant foot - assumed 'foot' in /in/3b26v on line 45 Notice: Use of undefined constant bus - assumed 'bus' in /in/3b26v on line 53 Notice: Use of undefined constant foot - assumed 'foot' in /in/3b26v on line 54 two Notice: Use of undefined constant neighbors - assumed 'neighbors' in /in/3b26v on line 76 Notice: Undefined index: two in /in/3b26v on line 76 three Notice: Use of undefined constant neighbors - assumed 'neighbors' in /in/3b26v on line 76 Notice: Undefined index: three in /in/3b26v on line 76 fow Notice: Use of undefined constant neighbors - assumed 'neighbors' in /in/3b26v on line 76 Notice: Undefined index: fow in /in/3b26v on line 76 five Notice: Use of undefined constant neighbors - assumed 'neighbors' in /in/3b26v on line 76 Notice: Undefined index: five in /in/3b26v on line 76 six Notice: Use of undefined constant neighbors - assumed 'neighbors' in /in/3b26v on line 76 Notice: Undefined index: six in /in/3b26v on line 76 six Notice: Use of undefined constant neighbors - assumed 'neighbors' in /in/3b26v on line 76 Notice: Undefined index: six in /in/3b26v on line 76
Output for hhvm-3.15.4
Notice: Use of undefined constant bus - assumed 'bus' in /in/3b26v on line 8 Notice: Use of undefined constant subway - assumed 'subway' in /in/3b26v on line 9 Notice: Use of undefined constant bus - assumed 'bus' in /in/3b26v on line 10 Notice: Use of undefined constant bus - assumed 'bus' in /in/3b26v on line 18 Notice: Use of undefined constant bus - assumed 'bus' in /in/3b26v on line 26 Notice: Use of undefined constant foot - assumed 'foot' in /in/3b26v on line 27 Notice: Use of undefined constant bus - assumed 'bus' in /in/3b26v on line 35 Notice: Use of undefined constant bus - assumed 'bus' in /in/3b26v on line 36 Notice: Use of undefined constant bus - assumed 'bus' in /in/3b26v on line 44 Notice: Use of undefined constant foot - assumed 'foot' in /in/3b26v on line 45 Notice: Use of undefined constant bus - assumed 'bus' in /in/3b26v on line 53 Notice: Use of undefined constant foot - assumed 'foot' in /in/3b26v on line 54 two Notice: Use of undefined constant neighbors - assumed 'neighbors' in /in/3b26v on line 76 Notice: Undefined index: two in /in/3b26v on line 76 three Notice: Use of undefined constant neighbors - assumed 'neighbors' in /in/3b26v on line 76 Notice: Undefined index: three in /in/3b26v on line 76 fow five six six