3v4l.org

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

Function sort_by_a:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Gn8Jr
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%2FGn8Jr%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%2FGn8Jr%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/Gn8Jr
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%2FGn8Jr%3A36%240

Function sort_by_b:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Gn8Jr
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%2FGn8Jr%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%2FGn8Jr%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/Gn8Jr
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%2FGn8Jr%3A46%241

Function sort_by_c:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Gn8Jr
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%2FGn8Jr%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%2FGn8Jr%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/Gn8Jr
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%2FGn8Jr%3A56%242

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

End of function __construct

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.34 ms | 1419 KiB | 20 Q