3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test() { $orderedids=array(7, 9, 5, 3); $tags=array( new Tag(3), new Tag(7), new Tag(5), new Tag(9) ); $flipped=array_flip($orderedids); return usort($tags, function($tag1, $tag2) { if ($flipped[$tag1->id]<$flipped[$tag2->id]) return -1; else if ($flipped[$tag1->id]==$flipped[$tag2->id]) return 0; else return 1; }); } class Tag { public $id; function __construct($id) { $this->id=$id; } } $rtags=test(); foreach ($rtags as $tag) echo $tag->id." ";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/pDv7P
function name:  (null)
number of ops:  11
compiled vars:  !0 = $rtags, !1 = $tag
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   INIT_FCALL                                               'test'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   32     3      > FE_RESET_R                                       $4      !0, ->9
          4    > > FE_FETCH_R                                               $4, !1, ->9
          5    >   FETCH_OBJ_R                                      ~5      !1, 'id'
          6        CONCAT                                           ~6      ~5, '+'
          7        ECHO                                                     ~6
          8      > JMP                                                      ->4
          9    >   FE_FREE                                                  $4
         10      > RETURN                                                   1

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pDv7P
function name:  test
number of ops:  29
compiled vars:  !0 = $orderedids, !1 = $tags, !2 = $flipped
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, <array>
    7     1        NEW                                              $4      'Tag'
          2        SEND_VAL_EX                                              3
          3        DO_FCALL                                      0          
          4        INIT_ARRAY                                       ~6      $4
    8     5        NEW                                              $7      'Tag'
          6        SEND_VAL_EX                                              7
          7        DO_FCALL                                      0          
          8        ADD_ARRAY_ELEMENT                                ~6      $7
    9     9        NEW                                              $9      'Tag'
         10        SEND_VAL_EX                                              5
         11        DO_FCALL                                      0          
         12        ADD_ARRAY_ELEMENT                                ~6      $9
   10    13        NEW                                              $11     'Tag'
         14        SEND_VAL_EX                                              9
         15        DO_FCALL                                      0          
         16        ADD_ARRAY_ELEMENT                                ~6      $11
    6    17        ASSIGN                                                   !1, ~6
   13    18        INIT_FCALL                                               'array_flip'
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                         $14     
         21        ASSIGN                                                   !2, $14
   15    22        INIT_FCALL                                               'usort'
         23        SEND_REF                                                 !1
         24        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FpDv7P%3A15%240'
   19    25        SEND_VAL                                                 ~16
         26        DO_ICALL                                         $17     
         27      > RETURN                                                   $17
   20    28*     > RETURN                                                   null

End of function test

Function %00%7Bclosure%7D%2Fin%2FpDv7P%3A15%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pDv7P
function name:  {closure}
number of ops:  20
compiled vars:  !0 = $tag1, !1 = $tag2, !2 = $flipped
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   16     2        FETCH_OBJ_R                                      ~3      !0, 'id'
          3        FETCH_DIM_R                                      ~4      !2, ~3
          4        FETCH_OBJ_R                                      ~5      !1, 'id'
          5        FETCH_DIM_R                                      ~6      !2, ~5
          6        IS_SMALLER                                               ~4, ~6
          7      > JMPZ                                                     ~7, ->10
          8    > > RETURN                                                   -1
          9*       JMP                                                      ->19
   17    10    >   FETCH_OBJ_R                                      ~8      !0, 'id'
         11        FETCH_DIM_R                                      ~9      !2, ~8
         12        FETCH_OBJ_R                                      ~10     !1, 'id'
         13        FETCH_DIM_R                                      ~11     !2, ~10
         14        IS_EQUAL                                                 ~9, ~11
         15      > JMPZ                                                     ~12, ->18
         16    > > RETURN                                                   0
         17*       JMP                                                      ->19
   18    18    > > RETURN                                                   1
   19    19*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FpDv7P%3A15%240

Class Tag:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pDv7P
function name:  __construct
number of ops:  4
compiled vars:  !0 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
   26     1        ASSIGN_OBJ                                               'id'
          2        OP_DATA                                                  !0
   27     3      > RETURN                                                   null

End of function __construct

End of class Tag.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.79 ms | 1403 KiB | 18 Q