3v4l.org

run code in 300+ PHP versions simultaneously
<?php function quicksort($array) { if (count($array) == 0) { return array(); } $pivot = array_shift($array); $left = $right = array(); foreach($array as $object){ if ($object < $pivot) { $left[] = $object; } else { $right[] = $object; } } return array_merge(quicksort($left), array($pivot), quicksort($right)); } var_dump(quicksort([4, 11, 2, 8, 10, 1, 5]));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OlZG5
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'quicksort'
          2        SEND_VAL                                                 <array>
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
          6      > RETURN                                                   1

Function quicksort:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 21
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 21
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 18
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/OlZG5
function name:  quicksort
number of ops:  36
compiled vars:  !0 = $array, !1 = $pivot, !2 = $left, !3 = $right, !4 = $object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        COUNT                                            ~5      !0
          2        IS_EQUAL                                                 ~5, 0
          3      > JMPZ                                                     ~6, ->5
    6     4    > > RETURN                                                   <array>
    9     5    >   INIT_FCALL                                               'array_shift'
          6        SEND_REF                                                 !0
          7        DO_ICALL                                         $7      
          8        ASSIGN                                                   !1, $7
   10     9        ASSIGN                                           ~9      !3, <array>
         10        ASSIGN                                                   !2, ~9
   12    11      > FE_RESET_R                                       $11     !0, ->21
         12    > > FE_FETCH_R                                               $11, !4, ->21
   13    13    >   IS_SMALLER                                               !4, !1
         14      > JMPZ                                                     ~12, ->18
   14    15    >   ASSIGN_DIM                                               !2
         16        OP_DATA                                                  !4
         17      > JMP                                                      ->20
   16    18    >   ASSIGN_DIM                                               !3
         19        OP_DATA                                                  !4
   12    20    > > JMP                                                      ->12
         21    >   FE_FREE                                                  $11
   20    22        INIT_FCALL                                               'array_merge'
         23        INIT_FCALL_BY_NAME                                       'quicksort'
         24        SEND_VAR_EX                                              !2
         25        DO_FCALL                                      0  $15     
         26        SEND_VAR                                                 $15
         27        INIT_ARRAY                                       ~16     !1
         28        SEND_VAL                                                 ~16
         29        INIT_FCALL_BY_NAME                                       'quicksort'
         30        SEND_VAR_EX                                              !3
         31        DO_FCALL                                      0  $17     
         32        SEND_VAR                                                 $17
         33        DO_ICALL                                         $18     
         34      > RETURN                                                   $18
   21    35*     > RETURN                                                   null

End of function quicksort

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.41 ms | 1403 KiB | 20 Q