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) { return array_search($a) - array_search($b); }); var_dump($myArray);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UvEk3
function name:  (null)
number of ops:  23
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%2FUvEk3%3A21%240'
   23    17        SEND_VAL                                                 ~11
         18        DO_ICALL                                                 
   25    19        INIT_FCALL                                               'var_dump'
         20        SEND_VAR                                                 !1
         21        DO_ICALL                                                 
         22      > RETURN                                                   1

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

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

Class Element:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UvEk3
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:
174.37 ms | 1400 KiB | 19 Q