3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public $a; public $b; public $c; public function __construct($a, $b, $c) { $this->a = $a; $this->b = $b; $this->c = $c; } } $arr = Array( new A('a1235d', 'f', 'M'), new A('a1235d', 'm', 'L'), new A('a1235d', 'm', 'S'), new A('a1234d', 'm', 'L'), new A('a1234d', 'm', 'S'), new A('a1236d', 'm', 'S'), new A('a1236d', 'm', 'M'), new A('a1234d', 'f', 'S'), new A('a1236d', 'f', 'S'), new A('a1236d', 'f', 'M'), new A('a1235d', 'f', 'S'), new A('a1234d', 'm', 'M'), new A('a1235d', 'm', 'M'), new A('a1234d', 'f', 'M'), new A('a1235d', 'f', 'L'), new A('a1236d', 'm', 'L'), new A('a1236d', 'f', 'L'), new A('a1234d', 'f', 'L') ); function sort_by_a($arr) { usort($arr, function($a, $b) { if ($a->a == $b->a) { return 0; } return ($a->a < $b->a) ? -1 : 1; }); return $arr; } function sort_by_b($arr) { usort($arr, function($a, $b) { if ($a->b == $b->b) { return 0; } return ($a->b < $b->b) ? -1 : 1; }); return $arr; } function sort_by_c($arr) { usort($arr, function($a, $b) { if ($a->c == $b->c) { return 0; } return ($a->c < $b->c) ? -1 : 1; }); return $arr; } function printarr($arr) { foreach ($arr as $a) echo $a->a."\t".$a->b."\t".$a->c."\n"; echo "\n"; } printarr($arr); $arr = sort_by_c($arr); printarr($arr); $arr = sort_by_b($arr); printarr($arr); $arr = sort_by_a($arr); printarr($arr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8P3bf
function name:  (null)
number of ops:  134
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   NEW                                              $1      'A'
          1        SEND_VAL_EX                                              'a1235d'
          2        SEND_VAL_EX                                              'f'
          3        SEND_VAL_EX                                              'M'
          4        DO_FCALL                                      0          
          5        INIT_ARRAY                                       ~3      $1
   16     6        NEW                                              $4      'A'
          7        SEND_VAL_EX                                              'a1235d'
          8        SEND_VAL_EX                                              'm'
          9        SEND_VAL_EX                                              'L'
         10        DO_FCALL                                      0          
         11        ADD_ARRAY_ELEMENT                                ~3      $4
   17    12        NEW                                              $6      'A'
         13        SEND_VAL_EX                                              'a1235d'
         14        SEND_VAL_EX                                              'm'
         15        SEND_VAL_EX                                              'S'
         16        DO_FCALL                                      0          
         17        ADD_ARRAY_ELEMENT                                ~3      $6
   18    18        NEW                                              $8      'A'
         19        SEND_VAL_EX                                              'a1234d'
         20        SEND_VAL_EX                                              'm'
         21        SEND_VAL_EX                                              'L'
         22        DO_FCALL                                      0          
         23        ADD_ARRAY_ELEMENT                                ~3      $8
   19    24        NEW                                              $10     'A'
         25        SEND_VAL_EX                                              'a1234d'
         26        SEND_VAL_EX                                              'm'
         27        SEND_VAL_EX                                              'S'
         28        DO_FCALL                                      0          
         29        ADD_ARRAY_ELEMENT                                ~3      $10
   20    30        NEW                                              $12     'A'
         31        SEND_VAL_EX                                              'a1236d'
         32        SEND_VAL_EX                                              'm'
         33        SEND_VAL_EX                                              'S'
         34        DO_FCALL                                      0          
         35        ADD_ARRAY_ELEMENT                                ~3      $12
   21    36        NEW                                              $14     'A'
         37        SEND_VAL_EX                                              'a1236d'
         38        SEND_VAL_EX                                              'm'
         39        SEND_VAL_EX                                              'M'
         40        DO_FCALL                                      0          
         41        ADD_ARRAY_ELEMENT                                ~3      $14
   22    42        NEW                                              $16     'A'
         43        SEND_VAL_EX                                              'a1234d'
         44        SEND_VAL_EX                                              'f'
         45        SEND_VAL_EX                                              'S'
         46        DO_FCALL                                      0          
         47        ADD_ARRAY_ELEMENT                                ~3      $16
   23    48        NEW                                              $18     'A'
         49        SEND_VAL_EX                                              'a1236d'
         50        SEND_VAL_EX                                              'f'
         51        SEND_VAL_EX                                              'S'
         52        DO_FCALL                                      0          
         53        ADD_ARRAY_ELEMENT                                ~3      $18
   24    54        NEW                                              $20     'A'
         55        SEND_VAL_EX                                              'a1236d'
         56        SEND_VAL_EX                                              'f'
         57        SEND_VAL_EX                                              'M'
         58        DO_FCALL                                      0          
         59        ADD_ARRAY_ELEMENT                                ~3      $20
   25    60        NEW                                              $22     'A'
         61        SEND_VAL_EX                                              'a1235d'
         62        SEND_VAL_EX                                              'f'
         63        SEND_VAL_EX                                              'S'
         64        DO_FCALL                                      0          
         65        ADD_ARRAY_ELEMENT                                ~3      $22
   26    66        NEW                                              $24     'A'
         67        SEND_VAL_EX                                              'a1234d'
         68        SEND_VAL_EX                                              'm'
         69        SEND_VAL_EX                                              'M'
         70        DO_FCALL                                      0          
         71        ADD_ARRAY_ELEMENT                                ~3      $24
   27    72        NEW                                              $26     'A'
         73        SEND_VAL_EX                                              'a1235d'
         74        SEND_VAL_EX                                              'm'
         75        SEND_VAL_EX                                              'M'
         76        DO_FCALL                                      0          
         77        ADD_ARRAY_ELEMENT                                ~3      $26
   28    78        NEW                                              $28     'A'
         79        SEND_VAL_EX                                              'a1234d'
         80        SEND_VAL_EX                                              'f'
         81        SEND_VAL_EX                                              'M'
         82        DO_FCALL                                      0          
         83        ADD_ARRAY_ELEMENT                                ~3      $28
   29    84        NEW                                              $30     'A'
         85        SEND_VAL_EX                                              'a1235d'
         86        SEND_VAL_EX                                              'f'
         87        SEND_VAL_EX                                              'L'
         88        DO_FCALL                                      0          
         89        ADD_ARRAY_ELEMENT                                ~3      $30
   30    90        NEW                                              $32     'A'
         91        SEND_VAL_EX                                              'a1236d'
         92        SEND_VAL_EX                                              'm'
         93        SEND_VAL_EX                                              'L'
         94        DO_FCALL                                      0          
         95        ADD_ARRAY_ELEMENT                                ~3      $32
   31    96        NEW                                              $34     'A'
         97        SEND_VAL_EX                                              'a1236d'
         98        SEND_VAL_EX                                              'f'
         99        SEND_VAL_EX                                              'L'
        100        DO_FCALL                                      0          
        101        ADD_ARRAY_ELEMENT                                ~3      $34
   32   102        NEW                                              $36     'A'
        103        SEND_VAL_EX                                              'a1234d'
        104        SEND_VAL_EX                                              'f'
        105        SEND_VAL_EX                                              'L'
        106        DO_FCALL                                      0          
        107        ADD_ARRAY_ELEMENT                                ~3      $36
   14   108        ASSIGN                                                   !0, ~3
   71   109        INIT_FCALL                                               'printarr'
        110        SEND_VAR                                                 !0
        111        DO_FCALL                                      0          
   72   112        INIT_FCALL                                               'sort_by_c'
        113        SEND_VAR                                                 !0
        114        DO_FCALL                                      0  $40     
        115        ASSIGN                                                   !0, $40
   73   116        INIT_FCALL                                               'printarr'
        117        SEND_VAR                                                 !0
        118        DO_FCALL                                      0          
   74   119        INIT_FCALL                                               'sort_by_b'
        120        SEND_VAR                                                 !0
        121        DO_FCALL                                      0  $43     
        122        ASSIGN                                                   !0, $43
   75   123        INIT_FCALL                                               'printarr'
        124        SEND_VAR                                                 !0
        125        DO_FCALL                                      0          
   76   126        INIT_FCALL                                               'sort_by_a'
        127        SEND_VAR                                                 !0
        128        DO_FCALL                                      0  $46     
        129        ASSIGN                                                   !0, $46
   77   130        INIT_FCALL                                               'printarr'
        131        SEND_VAR                                                 !0
        132        DO_FCALL                                      0          
        133      > RETURN                                                   1

Function sort_by_a:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8P3bf
function name:  sort_by_a
number of ops:  8
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
   36     1        INIT_FCALL                                               'usort'
          2        SEND_REF                                                 !0
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F8P3bf%3A36%240'
   41     4        SEND_VAL                                                 ~1
          5        DO_ICALL                                                 
   42     6      > RETURN                                                   !0
   43     7*     > RETURN                                                   null

End of function sort_by_a

Function %00%7Bclosure%7D%2Fin%2F8P3bf%3A36%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8P3bf
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   37     2        FETCH_OBJ_R                                      ~2      !0, 'a'
          3        FETCH_OBJ_R                                      ~3      !1, 'a'
          4        IS_EQUAL                                                 ~2, ~3
          5      > JMPZ                                                     ~4, ->7
   38     6    > > RETURN                                                   0
   40     7    >   FETCH_OBJ_R                                      ~5      !0, 'a'
          8        FETCH_OBJ_R                                      ~6      !1, 'a'
          9        IS_SMALLER                                               ~5, ~6
         10      > JMPZ                                                     ~7, ->13
         11    >   QM_ASSIGN                                        ~8      -1
         12      > JMP                                                      ->14
         13    >   QM_ASSIGN                                        ~8      1
         14    > > RETURN                                                   ~8
   41    15*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F8P3bf%3A36%240

Function sort_by_b:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8P3bf
function name:  sort_by_b
number of ops:  8
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   RECV                                             !0      
   46     1        INIT_FCALL                                               'usort'
          2        SEND_REF                                                 !0
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F8P3bf%3A46%241'
   51     4        SEND_VAL                                                 ~1
          5        DO_ICALL                                                 
   52     6      > RETURN                                                   !0
   53     7*     > RETURN                                                   null

End of function sort_by_b

Function %00%7Bclosure%7D%2Fin%2F8P3bf%3A46%241:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8P3bf
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   47     2        FETCH_OBJ_R                                      ~2      !0, 'b'
          3        FETCH_OBJ_R                                      ~3      !1, 'b'
          4        IS_EQUAL                                                 ~2, ~3
          5      > JMPZ                                                     ~4, ->7
   48     6    > > RETURN                                                   0
   50     7    >   FETCH_OBJ_R                                      ~5      !0, 'b'
          8        FETCH_OBJ_R                                      ~6      !1, 'b'
          9        IS_SMALLER                                               ~5, ~6
         10      > JMPZ                                                     ~7, ->13
         11    >   QM_ASSIGN                                        ~8      -1
         12      > JMP                                                      ->14
         13    >   QM_ASSIGN                                        ~8      1
         14    > > RETURN                                                   ~8
   51    15*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F8P3bf%3A46%241

Function sort_by_c:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8P3bf
function name:  sort_by_c
number of ops:  8
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   55     0  E >   RECV                                             !0      
   56     1        INIT_FCALL                                               'usort'
          2        SEND_REF                                                 !0
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F8P3bf%3A56%242'
   61     4        SEND_VAL                                                 ~1
          5        DO_ICALL                                                 
   62     6      > RETURN                                                   !0
   63     7*     > RETURN                                                   null

End of function sort_by_c

Function %00%7Bclosure%7D%2Fin%2F8P3bf%3A56%242:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8P3bf
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   56     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   57     2        FETCH_OBJ_R                                      ~2      !0, 'c'
          3        FETCH_OBJ_R                                      ~3      !1, 'c'
          4        IS_EQUAL                                                 ~2, ~3
          5      > JMPZ                                                     ~4, ->7
   58     6    > > RETURN                                                   0
   60     7    >   FETCH_OBJ_R                                      ~5      !0, 'c'
          8        FETCH_OBJ_R                                      ~6      !1, 'c'
          9        IS_SMALLER                                               ~5, ~6
         10      > JMPZ                                                     ~7, ->13
         11    >   QM_ASSIGN                                        ~8      -1
         12      > JMP                                                      ->14
         13    >   QM_ASSIGN                                        ~8      1
         14    > > RETURN                                                   ~8
   61    15*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F8P3bf%3A56%242

Function printarr:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 13
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 13
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/8P3bf
function name:  printarr
number of ops:  16
compiled vars:  !0 = $arr, !1 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   65     0  E >   RECV                                             !0      
   66     1      > FE_RESET_R                                       $2      !0, ->13
          2    > > FE_FETCH_R                                               $2, !1, ->13
   67     3    >   FETCH_OBJ_R                                      ~3      !1, 'a'
          4        CONCAT                                           ~4      ~3, '%09'
          5        FETCH_OBJ_R                                      ~5      !1, 'b'
          6        CONCAT                                           ~6      ~4, ~5
          7        CONCAT                                           ~7      ~6, '%09'
          8        FETCH_OBJ_R                                      ~8      !1, 'c'
          9        CONCAT                                           ~9      ~7, ~8
         10        CONCAT                                           ~10     ~9, '%0A'
         11        ECHO                                                     ~10
   66    12      > JMP                                                      ->2
         13    >   FE_FREE                                                  $2
   68    14        ECHO                                                     '%0A'
   69    15      > RETURN                                                   null

End of function printarr

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

End of function __construct

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.47 ms | 1419 KiB | 22 Q