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/>"; foreach($Old as &$O) { $State = OffReqState($O, $New); $O["Active"] = ($State !== false) ? $State : 2; } foreach($New as $N) { echo $N."<br/>"; if(OffReqState($N, $Old) === false) { $Old[] = $N; } } 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/HYj1E
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                                                 
   36     9      > RETURN                                                   1

Function mergeofreqs:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 4, Position 2 = 18
Branch analysis from position: 4
2 jumps found. (Code = 126) Position 1 = 5, Position 2 = 18
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 18
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 32
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 32
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 31
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 31
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
Branch analysis from position: 18
filename:       /in/HYj1E
function name:  MergeOfReqs
number of ops:  36
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        ECHO                                                     '----%3Cbr%2F%3E'
    8     3      > FE_RESET_RW                                      $5      !0, ->18
          4    > > FE_FETCH_RW                                              $5, !2, ->18
   10     5    >   INIT_FCALL_BY_NAME                                       'OffReqState'
          6        SEND_VAR_EX                                              !2
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0  $6      
          9        ASSIGN                                                   !3, $6
   11    10        TYPE_CHECK                                  1018          !3
         11      > JMPZ                                                     ~9, ->14
         12    >   QM_ASSIGN                                        ~10     !3
         13      > JMP                                                      ->15
         14    >   QM_ASSIGN                                        ~10     2
         15    >   ASSIGN_DIM                                               !2, 'Active'
         16        OP_DATA                                                  ~10
    8    17      > JMP                                                      ->4
         18    >   FE_FREE                                                  $5
   13    19      > FE_RESET_R                                       $11     !1, ->32
         20    > > FE_FETCH_R                                               $11, !4, ->32
   15    21    >   CONCAT                                           ~12     !4, '%3Cbr%2F%3E'
         22        ECHO                                                     ~12
   16    23        INIT_FCALL_BY_NAME                                       'OffReqState'
         24        SEND_VAR_EX                                              !4
         25        SEND_VAR_EX                                              !0
         26        DO_FCALL                                      0  $13     
         27        TYPE_CHECK                                    4          $13
         28      > JMPZ                                                     ~14, ->31
   18    29    >   ASSIGN_DIM                                               !0
         30        OP_DATA                                                  !4
   13    31    > > JMP                                                      ->20
         32    >   FE_FREE                                                  $11
   21    33        ECHO                                                     '-----%3Cbr%2F%3E%3Cbr%2F%3E'
   22    34      > RETURN                                                   !0
   23    35*     > 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/HYj1E
function name:  OffReqState
number of ops:  19
compiled vars:  !0 = $Elem, !1 = $Array, !2 = $Element
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   28     2      > FE_RESET_R                                       $3      !1, ->16
          3    > > FE_FETCH_R                                               $3, !2, ->16
   30     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
   32    12    >   FETCH_DIM_R                                      ~8      !0, 'Active'
         13        FE_FREE                                                  $3
         14      > RETURN                                                   ~8
   28    15    > > JMP                                                      ->3
         16    >   FE_FREE                                                  $3
   35    17      > RETURN                                                   <false>
   36    18*     > RETURN                                                   null

End of function offreqstate

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.81 ms | 1404 KiB | 17 Q