3v4l.org

run code in 300+ PHP versions simultaneously
<?php class GeoCoder { protected $latitude; protected $longitude; public $distance; public function __construct($lat,$long,$dist) { $this->latitude = $lat; $this->longitude = $long; $this->distance = $dist; } } $o1 = new GeoCoder(-22.43,-46.81,1500.00); $o2 = new GeoCoder(-22.42,-46.82,1740.00); $o3 = new GeoCoder(-21.43,-46.80,152.00); $array = array($o1, $o2, $o3); function quickSort( &$array ) { $cur = 1; $stack[1]['l'] = 0; $stack[1]['r'] = count($array)-1; do { $l = $stack[$cur]['l']; $r = $stack[$cur]['r']; $cur--; do { $i = $l; $j = $r; $tmp = $array[(int)( ($l+$r)/2 )]; // partion the array in two parts. // left from $tmp are with smaller values, // right from $tmp are with bigger ones do { while( $array[$i]->distance < $tmp->distance ) $i++; while( $tmp->distance < $array[$j]->distance ) $j--; // swap elements from the two sides if( $i <= $j) { $w = $array[$i]; $array[$i] = $array[$j]; $array[$j] = $w; $i++; $j--; } }while( $i <= $j ); if( $i < $r ) { $cur++; $stack[$cur]['l'] = $i; $stack[$cur]['r'] = $r; } $r = $j; }while( $l < $r ); }while( $cur != 0 ); } var_dump(quickSort($array));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EUW7d
function name:  (null)
number of ops:  29
compiled vars:  !0 = $o1, !1 = $o2, !2 = $o3, !3 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   NEW                                              $4      'GeoCoder'
          1        SEND_VAL_EX                                              -22.43
          2        SEND_VAL_EX                                              -46.81
          3        SEND_VAL_EX                                              1500
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $4
   16     6        NEW                                              $7      'GeoCoder'
          7        SEND_VAL_EX                                              -22.42
          8        SEND_VAL_EX                                              -46.82
          9        SEND_VAL_EX                                              1740
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !1, $7
   17    12        NEW                                              $10     'GeoCoder'
         13        SEND_VAL_EX                                              -21.43
         14        SEND_VAL_EX                                              -46.8
         15        SEND_VAL_EX                                              152
         16        DO_FCALL                                      0          
         17        ASSIGN                                                   !2, $10
   19    18        INIT_ARRAY                                       ~13     !0
         19        ADD_ARRAY_ELEMENT                                ~13     !1
         20        ADD_ARRAY_ELEMENT                                ~13     !2
         21        ASSIGN                                                   !3, ~13
   76    22        INIT_FCALL                                               'var_dump'
         23        INIT_FCALL                                               'quicksort'
         24        SEND_REF                                                 !3
         25        DO_FCALL                                      0  $15     
         26        SEND_VAR                                                 $15
         27        DO_ICALL                                                 
         28      > RETURN                                                   1

Function quicksort:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 25
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 32
Branch analysis from position: 38
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 49
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 51, Position 2 = 24
Branch analysis from position: 51
2 jumps found. (Code = 43) Position 1 = 53, Position 2 = 60
Branch analysis from position: 53
2 jumps found. (Code = 44) Position 1 = 63, Position 2 = 17
Branch analysis from position: 63
2 jumps found. (Code = 44) Position 1 = 65, Position 2 = 10
Branch analysis from position: 65
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
Branch analysis from position: 17
Branch analysis from position: 60
Branch analysis from position: 24
Branch analysis from position: 49
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 32
Branch analysis from position: 38
Branch analysis from position: 32
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 25
Branch analysis from position: 31
Branch analysis from position: 25
filename:       /in/EUW7d
function name:  quickSort
number of ops:  66
compiled vars:  !0 = $array, !1 = $cur, !2 = $stack, !3 = $l, !4 = $r, !5 = $i, !6 = $j, !7 = $tmp, !8 = $w
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   23     1        ASSIGN                                                   !1, 1
   24     2        FETCH_DIM_W                                      $10     !2, 1
          3        ASSIGN_DIM                                               $10, 'l'
          4        OP_DATA                                                  0
   25     5        COUNT                                            ~14     !0
          6        SUB                                              ~15     ~14, 1
          7        FETCH_DIM_W                                      $12     !2, 1
          8        ASSIGN_DIM                                               $12, 'r'
          9        OP_DATA                                                  ~15
   29    10    >   FETCH_DIM_R                                      ~16     !2, !1
         11        FETCH_DIM_R                                      ~17     ~16, 'l'
         12        ASSIGN                                                   !3, ~17
   30    13        FETCH_DIM_R                                      ~19     !2, !1
         14        FETCH_DIM_R                                      ~20     ~19, 'r'
         15        ASSIGN                                                   !4, ~20
   31    16        PRE_DEC                                                  !1
   35    17    >   ASSIGN                                                   !5, !3
   36    18        ASSIGN                                                   !6, !4
   37    19        ADD                                              ~25     !3, !4
         20        DIV                                              ~26     ~25, 2
         21        CAST                                          4  ~27     ~26
         22        FETCH_DIM_R                                      ~28     !0, ~27
         23        ASSIGN                                                   !7, ~28
   44    24    > > JMP                                                      ->26
   45    25    >   PRE_INC                                                  !5
   44    26    >   FETCH_DIM_R                                      ~31     !0, !5
         27        FETCH_OBJ_R                                      ~32     ~31, 'distance'
         28        FETCH_OBJ_R                                      ~33     !7, 'distance'
         29        IS_SMALLER                                               ~32, ~33
         30      > JMPNZ                                                    ~34, ->25
   47    31    > > JMP                                                      ->33
   48    32    >   PRE_DEC                                                  !6
   47    33    >   FETCH_OBJ_R                                      ~36     !7, 'distance'
         34        FETCH_DIM_R                                      ~37     !0, !6
         35        FETCH_OBJ_R                                      ~38     ~37, 'distance'
         36        IS_SMALLER                                               ~36, ~38
         37      > JMPNZ                                                    ~39, ->32
   51    38    >   IS_SMALLER_OR_EQUAL                                      !5, !6
         39      > JMPZ                                                     ~40, ->49
   53    40    >   FETCH_DIM_R                                      ~41     !0, !5
         41        ASSIGN                                                   !8, ~41
   54    42        FETCH_DIM_R                                      ~44     !0, !6
         43        ASSIGN_DIM                                               !0, !5
         44        OP_DATA                                                  ~44
   55    45        ASSIGN_DIM                                               !0, !6
         46        OP_DATA                                                  !8
   57    47        PRE_INC                                                  !5
   58    48        PRE_DEC                                                  !6
   61    49    >   IS_SMALLER_OR_EQUAL                                      !5, !6
         50      > JMPNZ                                                    ~48, ->24
   63    51    >   IS_SMALLER                                               !5, !4
         52      > JMPZ                                                     ~49, ->60
   65    53    >   PRE_INC                                                  !1
   66    54        FETCH_DIM_W                                      $51     !2, !1
         55        ASSIGN_DIM                                               $51, 'l'
         56        OP_DATA                                                  !5
   67    57        FETCH_DIM_W                                      $53     !2, !1
         58        ASSIGN_DIM                                               $53, 'r'
         59        OP_DATA                                                  !4
   69    60    >   ASSIGN                                                   !4, !6
   71    61        IS_SMALLER                                               !3, !4
         62      > JMPNZ                                                    ~56, ->17
   73    63    >   IS_NOT_EQUAL                                             !1, 0
         64      > JMPNZ                                                    ~57, ->10
   74    65    > > RETURN                                                   null

End of function quicksort

Class GeoCoder:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EUW7d
function name:  __construct
number of ops:  10
compiled vars:  !0 = $lat, !1 = $long, !2 = $dist
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    9     3        ASSIGN_OBJ                                               'latitude'
          4        OP_DATA                                                  !0
   10     5        ASSIGN_OBJ                                               'longitude'
          6        OP_DATA                                                  !1
   11     7        ASSIGN_OBJ                                               'distance'
          8        OP_DATA                                                  !2
   12     9      > RETURN                                                   null

End of function __construct

End of class GeoCoder.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.03 ms | 1407 KiB | 16 Q