3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* * Complete the 'mergeArrays' function below. * * The function is expected to return an INTEGER_ARRAY. * The function accepts following parameters: * 1. INTEGER_ARRAY a * 2. INTEGER_ARRAY b */ function mergeArrays($a, $b) { $mergedArray = array_merge($a, $b); $sortedMergedArray = sorter($mergedArray); // for($i=0; $i<count($sortedMergedArray);$i++){ // echo $sortedMergedArray[$i] . "\n"; // } foreach($sortedMergedArray as $value) { echo $value . "\n"; } } function sorter($array) { for($i=0; $i<count($array);$i++){ for($j=$i+1; $j<count($array);$j++){ if($array[$i] > $array[$j]) { $tmp = $array[$i]; $array[$i] = $array[$j]; $array[$j] = $tmp; } } } return $array; } $fptr = fopen(getenv("OUTPUT_PATH"), "w"); $a_count = intval(trim(fgets(STDIN))); $a = array(); for ($i = 0; $i < $a_count; $i++) { $a_item = intval(trim(fgets(STDIN))); $a[] = $a_item; } $b_count = intval(trim(fgets(STDIN))); $b = array(); for ($i = 0; $i < $b_count; $i++) { $b_item = intval(trim(fgets(STDIN))); $b[] = $b_item; } $result = mergeArrays($a, $b); var_dump($result);
Output for 8.0.0 - 8.0.3
Fatal error: Uncaught ValueError: Path cannot be empty in /in/eRMRL:43 Stack trace: #0 /in/eRMRL(43): fopen('', 'w') #1 {main} thrown in /in/eRMRL on line 43
Process exited with code 255.
Output for 7.1.25 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.28, 7.4.0 - 7.4.14
Warning: fopen(): Filename cannot be empty in /in/eRMRL on line 43 NULL