3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function mergeArray(array $arr1, array $arr2) { $keysStats = array(); foreach ($arr1 as $index => $key) { $keys[$key] = array( 'arr1' => $index, 'arr2' => null ); } foreach ($arr1 as $index => $key) { if (!is_array($keys[$key])) { $keys[$key] = array( 'arr1' => null; ) } $keys[$key]['arr2'] = $index; } $merged = array(); foreach (array_sort($keys) as $key => $score) { if (is_null($keys['arr2'])) { $merged[] = null; } else { $merged[] = $arr2[$keys['arr2']]; } } return $arrMerged; } print_r(mergeArray( array( 'a', 'b', 'c', 'd', 'e', 'f', 'g' ), array( 'a', 'b', 'z', 'q' ) ));
Output for 5.3.0 - 5.4.30
Parse error: syntax error, unexpected ';', expecting ')' in /in/RKZ6C on line 15
Process exited with code 255.