3v4l.org

run code in 300+ PHP versions simultaneously
<?php function quicksort( $array ) { if( count( $array ) < 2 ) { return $array; } $left = $right = array( ); reset( $array ); $pivot_key = key( $array ); $pivot = array_shift( $array ); foreach( $array as $k => $v ) { if( $v < $pivot ) $left[$k] = $v; else $right[$k] = $v; } return array_merge(quicksort($left), array($pivot_key => $pivot), quicksort($right)); } //Using quicksort() $array = quicksort( $array ); //returns sorted array.
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tXsnK
function name:  (null)
number of ops:  5
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_FCALL                                               'quicksort'
          1        SEND_VAR                                                 !0
          2        DO_FCALL                                      0  $1      
          3        ASSIGN                                                   !0, $1
          4      > 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 = 19, Position 2 = 29
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 29
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 26
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/tXsnK
function name:  quicksort
number of ops:  44
compiled vars:  !0 = $array, !1 = $left, !2 = $right, !3 = $pivot_key, !4 = $pivot, !5 = $v, !6 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        COUNT                                            ~7      !0
          2        IS_SMALLER                                               ~7, 2
          3      > JMPZ                                                     ~8, ->5
    4     4    > > RETURN                                                   !0
    6     5    >   ASSIGN                                           ~9      !2, <array>
          6        ASSIGN                                                   !1, ~9
    7     7        INIT_FCALL                                               'reset'
          8        SEND_REF                                                 !0
          9        DO_ICALL                                                 
    8    10        INIT_FCALL                                               'key'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $12     
         13        ASSIGN                                                   !3, $12
    9    14        INIT_FCALL                                               'array_shift'
         15        SEND_REF                                                 !0
         16        DO_ICALL                                         $14     
         17        ASSIGN                                                   !4, $14
   10    18      > FE_RESET_R                                       $16     !0, ->29
         19    > > FE_FETCH_R                                       ~17     $16, !5, ->29
         20    >   ASSIGN                                                   !6, ~17
   11    21        IS_SMALLER                                               !5, !4
         22      > JMPZ                                                     ~19, ->26
   12    23    >   ASSIGN_DIM                                               !1, !6
         24        OP_DATA                                                  !5
         25      > JMP                                                      ->28
   14    26    >   ASSIGN_DIM                                               !2, !6
         27        OP_DATA                                                  !5
   10    28    > > JMP                                                      ->19
         29    >   FE_FREE                                                  $16
   16    30        INIT_FCALL                                               'array_merge'
         31        INIT_FCALL_BY_NAME                                       'quicksort'
         32        SEND_VAR_EX                                              !1
         33        DO_FCALL                                      0  $22     
         34        SEND_VAR                                                 $22
         35        INIT_ARRAY                                       ~23     !4, !3
         36        SEND_VAL                                                 ~23
         37        INIT_FCALL_BY_NAME                                       'quicksort'
         38        SEND_VAR_EX                                              !2
         39        DO_FCALL                                      0  $24     
         40        SEND_VAR                                                 $24
         41        DO_ICALL                                         $25     
         42      > RETURN                                                   $25
   17    43*     > RETURN                                                   null

End of function quicksort

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.52 ms | 1402 KiB | 22 Q