3v4l.org

run code in 300+ PHP versions simultaneously
<?php $template = ['A', 'B', 'C']; $myArray = [ new Element('B'), new Element('C'), new Element('A'), ]; class Element { public $name; public function __construct($name) { $this->name = $name; } } usort($myArray, function($a, $b) use ($template) { return array_search($a, $template) - array_search($b, $template); }); var_dump($myArray);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dDb8T
function name:  (null)
number of ops:  24
compiled vars:  !0 = $template, !1 = $myArray
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, <array>
    6     1        NEW                                              $3      'Element'
          2        SEND_VAL_EX                                              'B'
          3        DO_FCALL                                      0          
          4        INIT_ARRAY                                       ~5      $3
    7     5        NEW                                              $6      'Element'
          6        SEND_VAL_EX                                              'C'
          7        DO_FCALL                                      0          
          8        ADD_ARRAY_ELEMENT                                ~5      $6
    8     9        NEW                                              $8      'Element'
         10        SEND_VAL_EX                                              'A'
         11        DO_FCALL                                      0          
         12        ADD_ARRAY_ELEMENT                                ~5      $8
    5    13        ASSIGN                                                   !1, ~5
   21    14        INIT_FCALL                                               'usort'
         15        SEND_REF                                                 !1
         16        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FdDb8T%3A21%240'
         17        BIND_LEXICAL                                             ~11, !0
   23    18        SEND_VAL                                                 ~11
         19        DO_ICALL                                                 
   25    20        INIT_FCALL                                               'var_dump'
         21        SEND_VAR                                                 !1
         22        DO_ICALL                                                 
         23      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FdDb8T%3A21%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dDb8T
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $a, !1 = $b, !2 = $template
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   22     3        INIT_FCALL                                               'array_search'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !2
          6        DO_ICALL                                         $3      
          7        INIT_FCALL                                               'array_search'
          8        SEND_VAR                                                 !1
          9        SEND_VAR                                                 !2
         10        DO_ICALL                                         $4      
         11        SUB                                              ~5      $3, $4
         12      > RETURN                                                   ~5
   23    13*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FdDb8T%3A21%240

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

End of function __construct

End of class Element.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.4 ms | 1400 KiB | 19 Q