3v4l.org

run code in 300+ PHP versions simultaneously
<?php function AlphabetSoup($data,$currentValues) { $result =[]; // foreach ($currentValues as $key => $value){ // if($data[$key] == $value) continue; // $result[$key] = $value; if($data['allocation_even'] ==! $currentValues['allocation_even']) { $result['allocation_even'] = $data['allocation_even']; } $differences = array_merge(array_diff(explode(',', $data['os_targeting']), explode(',' , $currentValues['os_targeting'])) , array_diff(explode(',', $currentValues['os_targeting']), explode(',' ,$data['os_targeting']))); if(!empty($differences)) { $result['os_targeting'] = $data['os_targeting']; } return $result; } $data = [ 'allocation_even' => '1' , 'os_targeting' => 'Mac_OS_X,Linux,Win']; $current = [ 'allocation_even' => '1' , 'os_targeting' => 'Win,Mac_OS_X,Linux', 'other_value'=>0]; print_r( AlphabetSoup($data,$current));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZMg4H
function name:  (null)
number of ops:  10
compiled vars:  !0 = $data, !1 = $current
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                   !0, <array>
   18     1        ASSIGN                                                   !1, <array>
   19     2        INIT_FCALL                                               'print_r'
          3        INIT_FCALL                                               'alphabetsoup'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function alphabetsoup:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 50
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 50
Branch analysis from position: 11
filename:       /in/ZMg4H
function name:  AlphabetSoup
number of ops:  52
compiled vars:  !0 = $data, !1 = $currentValues, !2 = $result, !3 = $differences
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2        ASSIGN                                                   !2, <array>
    7     3        FETCH_DIM_R                                      ~5      !0, 'allocation_even'
          4        FETCH_DIM_R                                      ~6      !1, 'allocation_even'
          5        BOOL_NOT                                         ~7      ~6
          6        IS_EQUAL                                                 ~5, ~7
          7      > JMPZ                                                     ~8, ->11
    8     8    >   FETCH_DIM_R                                      ~10     !0, 'allocation_even'
          9        ASSIGN_DIM                                               !2, 'allocation_even'
         10        OP_DATA                                                  ~10
   10    11    >   INIT_FCALL                                               'array_merge'
         12        INIT_FCALL                                               'array_diff'
         13        INIT_FCALL                                               'explode'
         14        SEND_VAL                                                 '%2C'
         15        FETCH_DIM_R                                      ~11     !0, 'os_targeting'
         16        SEND_VAL                                                 ~11
         17        DO_ICALL                                         $12     
         18        SEND_VAR                                                 $12
         19        INIT_FCALL                                               'explode'
         20        SEND_VAL                                                 '%2C'
         21        FETCH_DIM_R                                      ~13     !1, 'os_targeting'
         22        SEND_VAL                                                 ~13
         23        DO_ICALL                                         $14     
         24        SEND_VAR                                                 $14
         25        DO_ICALL                                         $15     
         26        SEND_VAR                                                 $15
   11    27        INIT_FCALL                                               'array_diff'
         28        INIT_FCALL                                               'explode'
         29        SEND_VAL                                                 '%2C'
         30        FETCH_DIM_R                                      ~16     !1, 'os_targeting'
         31        SEND_VAL                                                 ~16
         32        DO_ICALL                                         $17     
         33        SEND_VAR                                                 $17
         34        INIT_FCALL                                               'explode'
         35        SEND_VAL                                                 '%2C'
         36        FETCH_DIM_R                                      ~18     !0, 'os_targeting'
         37        SEND_VAL                                                 ~18
         38        DO_ICALL                                         $19     
         39        SEND_VAR                                                 $19
         40        DO_ICALL                                         $20     
         41        SEND_VAR                                                 $20
         42        DO_ICALL                                         $21     
   10    43        ASSIGN                                                   !3, $21
   12    44        ISSET_ISEMPTY_CV                                 ~23     !3
         45        BOOL_NOT                                         ~24     ~23
         46      > JMPZ                                                     ~24, ->50
   13    47    >   FETCH_DIM_R                                      ~26     !0, 'os_targeting'
         48        ASSIGN_DIM                                               !2, 'os_targeting'
         49        OP_DATA                                                  ~26
   15    50    > > RETURN                                                   !2
   16    51*     > RETURN                                                   null

End of function alphabetsoup

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.84 ms | 1403 KiB | 22 Q