3v4l.org

run code in 300+ PHP versions simultaneously
<?php $Old = array(array("Subject"=>"Informatik 1", "Active"=>"1")); $New = array(array("Subject"=>"Informatik 1", "Active"=>"0", "Subject"=>"Informatik 2", "Active"=>"1")); var_dump(MergeOfReqs($Old, $New)); function MergeOfReqs($Old, $New) { echo"----<br/>".print_r($Old, true)."<br/>--<br/>".print_r($New, true)."<br/>--<br/>"; foreach($Old as &$O) { echo print_r($O, true)."<br/>"; $State = OffReqState($O, $New); $O["Active"] = ($State !== false) ? $State : 2; } echo"<br/>--<br/>"; foreach($New as $N) { echo print_r($N, true)."<br/>"; if(OffReqState($N, $Old) === false) { $Old[] = $N; } } echo "<br/>--<br/>".print_r($Old, true)."<br/>"; echo"-----<br/><br/>"; return $Old; } //And another shitty/crappy name function OffReqState($Elem, $Array) { foreach($Array as $Element) { if(strcmp($Element["Subject"], $Elem["Subject"]) == 0) { return $Elem["Active"]; } } return false; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gL72e
function name:  (null)
number of ops:  10
compiled vars:  !0 = $Old, !1 = $New
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    3     1        ASSIGN                                                   !1, <array>
    4     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL_BY_NAME                                       'MergeOfReqs'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
   39     9      > RETURN                                                   1

Function mergeofreqs:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 16, Position 2 = 36
Branch analysis from position: 16
2 jumps found. (Code = 126) Position 1 = 17, Position 2 = 36
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 32
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 36
2 jumps found. (Code = 77) Position 1 = 39, Position 2 = 55
Branch analysis from position: 39
2 jumps found. (Code = 78) Position 1 = 40, Position 2 = 55
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 52, Position 2 = 54
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
Branch analysis from position: 54
Branch analysis from position: 55
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 55
Branch analysis from position: 36
filename:       /in/gL72e
function name:  MergeOfReqs
number of ops:  66
compiled vars:  !0 = $Old, !1 = $New, !2 = $O, !3 = $State, !4 = $N
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        INIT_FCALL                                               'print_r'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 <true>
          5        DO_ICALL                                         $5      
          6        CONCAT                                           ~6      '----%3Cbr%2F%3E', $5
          7        CONCAT                                           ~7      ~6, '%3Cbr%2F%3E--%3Cbr%2F%3E'
          8        INIT_FCALL                                               'print_r'
          9        SEND_VAR                                                 !1
         10        SEND_VAL                                                 <true>
         11        DO_ICALL                                         $8      
         12        CONCAT                                           ~9      ~7, $8
         13        CONCAT                                           ~10     ~9, '%3Cbr%2F%3E--%3Cbr%2F%3E'
         14        ECHO                                                     ~10
    8    15      > FE_RESET_RW                                      $11     !0, ->36
         16    > > FE_FETCH_RW                                              $11, !2, ->36
   10    17    >   INIT_FCALL                                               'print_r'
         18        SEND_VAR                                                 !2
         19        SEND_VAL                                                 <true>
         20        DO_ICALL                                         $12     
         21        CONCAT                                           ~13     $12, '%3Cbr%2F%3E'
         22        ECHO                                                     ~13
   11    23        INIT_FCALL_BY_NAME                                       'OffReqState'
         24        SEND_VAR_EX                                              !2
         25        SEND_VAR_EX                                              !1
         26        DO_FCALL                                      0  $14     
         27        ASSIGN                                                   !3, $14
   12    28        TYPE_CHECK                                  1018          !3
         29      > JMPZ                                                     ~17, ->32
         30    >   QM_ASSIGN                                        ~18     !3
         31      > JMP                                                      ->33
         32    >   QM_ASSIGN                                        ~18     2
         33    >   ASSIGN_DIM                                               !2, 'Active'
         34        OP_DATA                                                  ~18
    8    35      > JMP                                                      ->16
         36    >   FE_FREE                                                  $11
   14    37        ECHO                                                     '%3Cbr%2F%3E--%3Cbr%2F%3E'
   15    38      > FE_RESET_R                                       $19     !1, ->55
         39    > > FE_FETCH_R                                               $19, !4, ->55
   17    40    >   INIT_FCALL                                               'print_r'
         41        SEND_VAR                                                 !4
         42        SEND_VAL                                                 <true>
         43        DO_ICALL                                         $20     
         44        CONCAT                                           ~21     $20, '%3Cbr%2F%3E'
         45        ECHO                                                     ~21
   18    46        INIT_FCALL_BY_NAME                                       'OffReqState'
         47        SEND_VAR_EX                                              !4
         48        SEND_VAR_EX                                              !0
         49        DO_FCALL                                      0  $22     
         50        TYPE_CHECK                                    4          $22
         51      > JMPZ                                                     ~23, ->54
   20    52    >   ASSIGN_DIM                                               !0
         53        OP_DATA                                                  !4
   15    54    > > JMP                                                      ->39
         55    >   FE_FREE                                                  $19
   23    56        INIT_FCALL                                               'print_r'
         57        SEND_VAR                                                 !0
         58        SEND_VAL                                                 <true>
         59        DO_ICALL                                         $25     
         60        CONCAT                                           ~26     '%3Cbr%2F%3E--%3Cbr%2F%3E', $25
         61        CONCAT                                           ~27     ~26, '%3Cbr%2F%3E'
         62        ECHO                                                     ~27
   24    63        ECHO                                                     '-----%3Cbr%2F%3E%3Cbr%2F%3E'
   25    64      > RETURN                                                   !0
   26    65*     > RETURN                                                   null

End of function mergeofreqs

Function offreqstate:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 16
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 16
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/gL72e
function name:  OffReqState
number of ops:  19
compiled vars:  !0 = $Elem, !1 = $Array, !2 = $Element
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   31     2      > FE_RESET_R                                       $3      !1, ->16
          3    > > FE_FETCH_R                                               $3, !2, ->16
   33     4    >   INIT_FCALL                                               'strcmp'
          5        FETCH_DIM_R                                      ~4      !2, 'Subject'
          6        SEND_VAL                                                 ~4
          7        FETCH_DIM_R                                      ~5      !0, 'Subject'
          8        SEND_VAL                                                 ~5
          9        DO_ICALL                                         $6      
         10        IS_EQUAL                                                 $6, 0
         11      > JMPZ                                                     ~7, ->15
   35    12    >   FETCH_DIM_R                                      ~8      !0, 'Active'
         13        FE_FREE                                                  $3
         14      > RETURN                                                   ~8
   31    15    > > JMP                                                      ->3
         16    >   FE_FREE                                                  $3
   38    17      > RETURN                                                   <false>
   39    18*     > RETURN                                                   null

End of function offreqstate

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.15 ms | 1396 KiB | 19 Q