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; } $result = mergeArrays([1,2], [3,4]); var_dump($result);
based on eRMRL
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3HTmt
function name:  (null)
number of ops:  9
compiled vars:  !0 = $result
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  43     0  E >   INIT_FCALL                                               'mergearrays'
         1        SEND_VAL                                                 <array>
         2        SEND_VAL                                                 <array>
         3        DO_FCALL                                      0  $1      
         4        QM_ASSIGN                                                !0
  45     5        INIT_FCALL                                               'var_dump'
         6        SEND_VAR                                                 !0
         7        DO_ICALL                                                 
         8      > RETURN                                                   1

Function mergearrays:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/3HTmt
function name:  mergeArrays
number of ops:  18
compiled vars:  !0 = $a, !1 = $b, !2 = $mergedArray, !3 = $sortedMergedArray, !4 = $value
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  15     0  E >   RECV                                             !0      
         1        RECV                                             !1      
  17     2        INIT_FCALL                                               'array_merge'
         3        SEND_VAR                                                 !0
         4        SEND_VAR                                                 !1
         5        DO_ICALL                                         $5      
         6        QM_ASSIGN                                                !2
  18     7        INIT_FCALL_BY_NAME                                       'sorter'
         8        SEND_VAR_EX                                              !2
         9        DO_FCALL                                      0  $7      
        10        QM_ASSIGN                                                !3
  23    11      > FE_RESET_R                                       $9      !3, ->16
        12    > > FE_FETCH_R                                               $9, !4, ->16
  24    13    >   CONCAT                                           ~10     !4, '%0A'
        14        ASSIGN_OBJ                                               ~10
  23    15      > JMP                                                      ->12
        16    >   FE_FREE                                                  $9
  26    17      > RETURN                                                   null

End of function mergearrays

Function sorter:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 3
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 6
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 3
Branch analysis from position: 27
Branch analysis from position: 3
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 6
Branch analysis from position: 22
Branch analysis from position: 6
Branch analysis from position: 17
filename:       /in/3HTmt
function name:  sorter
number of ops:  29
compiled vars:  !0 = $array, !1 = $i, !2 = $j, !3 = $tmp
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  28     0  E >   RECV                                             !0      
  30     1        QM_ASSIGN                                                !1
         2      > JMP                                                      ->24
  31     3    >   ADD                                              ~5      !1, 1
         4        QM_ASSIGN                                                !2
         5      > JMP                                                      ->19
  32     6    >   FETCH_DIM_R                                      ~7      !0, !1
         7        FETCH_DIM_R                                      ~8      !0, !2
         8        IS_SMALLER_OR_EQUAL                              ~9      ~8, ~7
         9      > JMPZ                                                     ~9, ->17
  33    10    >   FETCH_DIM_R                                      ~10     !0, !1
        11        QM_ASSIGN                                                !3
  34    12        FETCH_DIM_R                                      ~13     !0, !2
        13        ASSIGN_ADD                                    0          !0, !1
        14        OP_DATA                                                  ~13
  35    15        ASSIGN_ADD                                    0          !0, !2
        16        OP_DATA                                                  !3
  31    17    >   POST_INC                                         ~15     !2
        18        FREE                                                     ~15
        19    >   COUNT                                            ~16     !0
        20        IS_SMALLER_OR_EQUAL                              ~17     !2, ~16
        21      > JMPNZ                                                    ~17, ->6
  30    22    >   POST_INC                                         ~18     !1
        23        FREE                                                     ~18
        24    >   COUNT                                            ~19     !0
        25        IS_SMALLER_OR_EQUAL                              ~20     !1, ~19
        26      > JMPNZ                                                    ~20, ->3
  40    27    > > RETURN                                                   !0
  41    28*     > RETURN                                                   null

End of function sorter

Generated using Vulcan Logic Dumper, using php 7.4.0