3v4l.org

run code in 300+ PHP versions simultaneously
<?php class NameObj { public $name; function __construct($name){ $this->name = $name; } } class IdObj{ public $id; function __construct($id){ $this->id = $id; } } $idArray = array( new IdObj(1), new IdObj(2), new IdObj(3) ); $nameArray = array( new NameObj('1 - Object 1 Name'), new NameObj('2 - Object 2 Name') ); function custom_diff($oId, $oName) { $one = $oId instanceof IdObj?$oId->id:explode(' - ', $oId->name)[0]; $two = $oName instanceof NameObj?explode(' - ', $oName->name)[0]:$oName->id; return $one-$two; } $missing_objects = array_udiff($idArray, $nameArray, 'custom_diff'); print_r($missing_objects);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/n694Z
function name:  (null)
number of ops:  32
compiled vars:  !0 = $idArray, !1 = $nameArray, !2 = $missing_objects
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   NEW                                              $3      'IdObj'
          1        SEND_VAL_EX                                              1
          2        DO_FCALL                                      0          
          3        INIT_ARRAY                                       ~5      $3
   23     4        NEW                                              $6      'IdObj'
          5        SEND_VAL_EX                                              2
          6        DO_FCALL                                      0          
          7        ADD_ARRAY_ELEMENT                                ~5      $6
   24     8        NEW                                              $8      'IdObj'
          9        SEND_VAL_EX                                              3
         10        DO_FCALL                                      0          
         11        ADD_ARRAY_ELEMENT                                ~5      $8
   21    12        ASSIGN                                                   !0, ~5
   28    13        NEW                                              $11     'NameObj'
         14        SEND_VAL_EX                                              '1+-+Object+1+Name'
         15        DO_FCALL                                      0          
         16        INIT_ARRAY                                       ~13     $11
   29    17        NEW                                              $14     'NameObj'
         18        SEND_VAL_EX                                              '2+-+Object+2+Name'
         19        DO_FCALL                                      0          
         20        ADD_ARRAY_ELEMENT                                ~13     $14
   27    21        ASSIGN                                                   !1, ~13
   40    22        INIT_FCALL                                               'array_udiff'
         23        SEND_VAR                                                 !0
         24        SEND_VAR                                                 !1
         25        SEND_VAL                                                 'custom_diff'
         26        DO_ICALL                                         $17     
         27        ASSIGN                                                   !2, $17
   42    28        INIT_FCALL                                               'print_r'
         29        SEND_VAR                                                 !2
         30        DO_ICALL                                                 
         31      > RETURN                                                   1

Function custom_diff:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 25
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 25
Branch analysis from position: 17
Branch analysis from position: 25
filename:       /in/n694Z
function name:  custom_diff
number of ops:  31
compiled vars:  !0 = $oId, !1 = $oName, !2 = $one, !3 = $two
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   35     2        INSTANCEOF                                               !0, 'IdObj'
          3      > JMPZ                                                     ~4, ->7
          4    >   FETCH_OBJ_R                                      ~5      !0, 'id'
          5        QM_ASSIGN                                        ~6      ~5
          6      > JMP                                                      ->14
          7    >   INIT_FCALL                                               'explode'
          8        SEND_VAL                                                 '+-+'
          9        FETCH_OBJ_R                                      ~7      !0, 'name'
         10        SEND_VAL                                                 ~7
         11        DO_ICALL                                         $8      
         12        FETCH_DIM_R                                      ~9      $8, 0
         13        QM_ASSIGN                                        ~6      ~9
         14    >   ASSIGN                                                   !2, ~6
   36    15        INSTANCEOF                                               !1, 'NameObj'
         16      > JMPZ                                                     ~11, ->25
         17    >   INIT_FCALL                                               'explode'
         18        SEND_VAL                                                 '+-+'
         19        FETCH_OBJ_R                                      ~12     !1, 'name'
         20        SEND_VAL                                                 ~12
         21        DO_ICALL                                         $13     
         22        FETCH_DIM_R                                      ~14     $13, 0
         23        QM_ASSIGN                                        ~15     ~14
         24      > JMP                                                      ->27
         25    >   FETCH_OBJ_R                                      ~16     !1, 'id'
         26        QM_ASSIGN                                        ~15     ~16
         27    >   ASSIGN                                                   !3, ~15
   37    28        SUB                                              ~18     !2, !3
         29      > RETURN                                                   ~18
   38    30*     > RETURN                                                   null

End of function custom_diff

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

End of function __construct

End of class NameObj.

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

End of function __construct

End of class IdObj.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.22 ms | 1400 KiB | 19 Q