3v4l.org

run code in 300+ PHP versions simultaneously
<?php $ar_val="134567,dogs,food,EEUU"; $ar_url="134567,dogs,toys,EEUU"; $arrayVal = explode($ar_val, ','); $arrayUrl = explode($ar_url, ','); $maxLength = max(sizeof($arrayVal), sizeof($arrayUrl)); $arrayIdsEqual = array(); $arrayIdsDifferent = array(); for ($i = 0; $i < $maxLength; $i++) { if (isset($arrayVal[$i]) && isset($arrayUrl[$i])) { if ($arrayVal[$i] == $arrayUrl[$i]) { $arrayIdsEqual[] = $i; } else { $arrayIdsDifferent[] = $i; } } else { //you arrive here if you have 2 arrays that don't have the same size / sme number of variables } } //assuming your 2 arrays ALWAYS have the same size, you can use the following logic if (empty($arrayIdsDifferent)) { echo '2 arrays are the same'; } else { echo 'Differences: '; foreach ($arrayIdsDifferent as $indexDifferent => $currentIdDifferent) { $output = 'difference ' . $indexDifferent + 1 . ': '; $output .= 'val = ' . $arrayVal[$currentIdDifferent]; $output .= 'url = ' . $arrayUrl[$currentIdDifferent]; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 23
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 45
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 61
Branch analysis from position: 61
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 45
2 jumps found. (Code = 77) Position 1 = 47, Position 2 = 60
Branch analysis from position: 47
2 jumps found. (Code = 78) Position 1 = 48, Position 2 = 60
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
Branch analysis from position: 60
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 60
Branch analysis from position: 23
2 jumps found. (Code = 46) Position 1 = 25, Position 2 = 27
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 38
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 35
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 23
Branch analysis from position: 41
Branch analysis from position: 23
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
Branch analysis from position: 38
Branch analysis from position: 27
filename:       /in/J2IDm
function name:  (null)
number of ops:  62
compiled vars:  !0 = $ar_val, !1 = $ar_url, !2 = $arrayVal, !3 = $arrayUrl, !4 = $maxLength, !5 = $arrayIdsEqual, !6 = $arrayIdsDifferent, !7 = $i, !8 = $currentIdDifferent, !9 = $indexDifferent, !10 = $output
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '134567%2Cdogs%2Cfood%2CEEUU'
    4     1        ASSIGN                                                   !1, '134567%2Cdogs%2Ctoys%2CEEUU'
    6     2        INIT_FCALL                                               'explode'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 '%2C'
          5        DO_ICALL                                         $13     
          6        ASSIGN                                                   !2, $13
    7     7        INIT_FCALL                                               'explode'
          8        SEND_VAR                                                 !1
          9        SEND_VAL                                                 '%2C'
         10        DO_ICALL                                         $15     
         11        ASSIGN                                                   !3, $15
    9    12        INIT_FCALL                                               'max'
         13        COUNT                                            ~17     !2
         14        SEND_VAL                                                 ~17
         15        COUNT                                            ~18     !3
         16        SEND_VAL                                                 ~18
         17        DO_ICALL                                         $19     
         18        ASSIGN                                                   !4, $19
   10    19        ASSIGN                                                   !5, <array>
   11    20        ASSIGN                                                   !6, <array>
   13    21        ASSIGN                                                   !7, 0
         22      > JMP                                                      ->39
   14    23    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~24     !2, !7
         24      > JMPZ_EX                                          ~24     ~24, ->27
         25    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~25     !3, !7
         26        BOOL                                             ~24     ~25
         27    > > JMPZ                                                     ~24, ->38
   15    28    >   FETCH_DIM_R                                      ~26     !2, !7
         29        FETCH_DIM_R                                      ~27     !3, !7
         30        IS_EQUAL                                                 ~26, ~27
         31      > JMPZ                                                     ~28, ->35
   16    32    >   ASSIGN_DIM                                               !5
         33        OP_DATA                                                  !7
         34      > JMP                                                      ->37
   19    35    >   ASSIGN_DIM                                               !6
         36        OP_DATA                                                  !7
         37    > > JMP                                                      ->38
   13    38    >   PRE_INC                                                  !7
         39    >   IS_SMALLER                                               !7, !4
         40      > JMPNZ                                                    ~32, ->23
   28    41    >   ISSET_ISEMPTY_CV                                         !6
         42      > JMPZ                                                     ~33, ->45
   29    43    >   ECHO                                                     '2+arrays+are+the+same'
         44      > JMP                                                      ->61
   32    45    >   ECHO                                                     'Differences%3A+'
   33    46      > FE_RESET_R                                       $34     !6, ->60
         47    > > FE_FETCH_R                                       ~35     $34, !8, ->60
         48    >   ASSIGN                                                   !9, ~35
   34    49        ADD                                              ~37     !9, 1
         50        CONCAT                                           ~38     'difference+', ~37
         51        CONCAT                                           ~39     ~38, '%3A+'
         52        ASSIGN                                                   !10, ~39
   35    53        FETCH_DIM_R                                      ~41     !2, !8
         54        CONCAT                                           ~42     'val+%3D+', ~41
         55        ASSIGN_OP                                     8          !10, ~42
   36    56        FETCH_DIM_R                                      ~44     !3, !8
         57        CONCAT                                           ~45     'url+%3D+', ~44
         58        ASSIGN_OP                                     8          !10, ~45
   33    59      > JMP                                                      ->47
         60    >   FE_FREE                                                  $34
   38    61    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.76 ms | 1400 KiB | 17 Q