3v4l.org

run code in 500+ PHP versions simultaneously
<?php //If you add to the end the varname as Mobin F.R.G suggest in the comments $text1 = array ('fr', 'hr', 'test1'); $text2 = array ('el', 'hr', 'test2'); $text3 = array ('bg', 'en', 'es', 'test3'); $text4 = array ('bg', 'el', 'en', 'es', 'test4'); $text5 = array ('bg', 'el', 'en', 'es', 'fr', 'hr', 'test5'); //I assume you didn't mean to make and array of array. $order1 = array('bg', 'el'); $finalstr = ''; $aux = 0; //Checks first element $containPrev1 = in_array($order1[0], $text1); $containPrev2 = in_array($order1[0], $text2); $containPrev3 = in_array($order1[0], $text3); $containPrev4 = in_array($order1[0], $text4); $containPrev5 = in_array($order1[0], $text5); while($aux< count($order1)){ if (in_array($order1[$aux], $text1) && $containPrev1 == true) { $lastpos = (count($text1)-1); if(strpos($finalstr, $text1[$lastpos]) == false){ $finalstr = $finalstr . $text1[$lastpos].' '; } } else{$containPrev1 = false;} if (in_array($order1[$aux], $text2) && $containPrev2 == true) { $lastpos = (count($text2)-1); if(strpos($finalstr, $text2[$lastpos]) == false){ $finalstr = $finalstr . $text2[$lastpos] . ' '; } } else{$containPrev2 = false;} if (in_array($order1[$aux], $text3) && $containPrev3 == true) { $lastpos = (count($text3)-1); if(strpos($finalstr, $text3[$lastpos]) == false){ $finalstr = $finalstr . $text3[$lastpos] . ' '; } } else{$containPrev3 = false;} if (in_array($order1[$aux], $text4) && $containPrev4 == true) { $lastpos = (count($text4)-1); if(strpos($finalstr, $text4[$lastpos]) == false){ $finalstr = $finalstr . $text4[$lastpos] . ' '; } } else{$containPrev4 = false;} if (in_array($order1[$aux], $text5) && $containPrev5 == true) { $lastpos = (count($text5)-1); if(strpos($finalstr, $text5[$lastpos]) == false){ $finalstr = $finalstr . $text5[$lastpos] . ' '; } } else{$containPrev5 = false;} $aux++; } //Just to print the string $finalstr = trim($finalstr); $arrayfinal = explode(" ", $finalstr); print_r($arrayfinal);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 120
Branch analysis from position: 120
2 jumps found. (Code = 44) Position 1 = 123, Position 2 = 24
Branch analysis from position: 123
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
2 jumps found. (Code = 46) Position 1 = 27, Position 2 = 29
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 42
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 41
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
2 jumps found. (Code = 46) Position 1 = 46, Position 2 = 48
Branch analysis from position: 46
2 jumps found. (Code = 43) Position 1 = 49, Position 2 = 61
Branch analysis from position: 49
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 60
Branch analysis from position: 56
1 jumps found. (Code = 42) Position 1 = 62
Branch analysis from position: 62
2 jumps found. (Code = 46) Position 1 = 65, Position 2 = 67
Branch analysis from position: 65
2 jumps found. (Code = 43) Position 1 = 68, Position 2 = 80
Branch analysis from position: 68
2 jumps found. (Code = 43) Position 1 = 75, Position 2 = 79
Branch analysis from position: 75
1 jumps found. (Code = 42) Position 1 = 81
Branch analysis from position: 81
2 jumps found. (Code = 46) Position 1 = 84, Position 2 = 86
Branch analysis from position: 84
2 jumps found. (Code = 43) Position 1 = 87, Position 2 = 99
Branch analysis from position: 87
2 jumps found. (Code = 43) Position 1 = 94, Position 2 = 98
Branch analysis from position: 94
1 jumps found. (Code = 42) Position 1 = 100
Branch analysis from position: 100
2 jumps found. (Code = 46) Position 1 = 103, Position 2 = 105
Branch analysis from position: 103
2 jumps found. (Code = 43) Position 1 = 106, Position 2 = 118
Branch analysis from position: 106
2 jumps found. (Code = 43) Position 1 = 113, Position 2 = 117
Branch analysis from position: 113
1 jumps found. (Code = 42) Position 1 = 119
Branch analysis from position: 119
2 jumps found. (Code = 44) Position 1 = 123, Position 2 = 24
Branch analysis from position: 123
Branch analysis from position: 24
Branch analysis from position: 117
Branch analysis from position: 118
2 jumps found. (Code = 44) Position 1 = 123, Position 2 = 24
Branch analysis from position: 123
Branch analysis from position: 24
Branch analysis from position: 105
Branch analysis from position: 98
Branch analysis from position: 99
2 jumps found. (Code = 46) Position 1 = 103, Position 2 = 105
Branch analysis from position: 103
Branch analysis from position: 105
Branch analysis from position: 86
Branch analysis from position: 79
Branch analysis from position: 80
2 jumps found. (Code = 46) Position 1 = 84, Position 2 = 86
Branch analysis from position: 84
Branch analysis from position: 86
Branch analysis from position: 67
Branch analysis from position: 60
Branch analysis from position: 61
2 jumps found. (Code = 46) Position 1 = 65, Position 2 = 67
Branch analysis from position: 65
Branch analysis from position: 67
Branch analysis from position: 48
Branch analysis from position: 41
Branch analysis from position: 42
2 jumps found. (Code = 46) Position 1 = 46, Position 2 = 48
Branch analysis from position: 46
Branch analysis from position: 48
Branch analysis from position: 29
filename:       /in/fDCgC
function name:  (null)
number of ops:  134
compiled vars:  !0 = $text1, !1 = $text2, !2 = $text3, !3 = $text4, !4 = $text5, !5 = $order1, !6 = $finalstr, !7 = $aux, !8 = $containPrev1, !9 = $containPrev2, !10 = $containPrev3, !11 = $containPrev4, !12 = $containPrev5, !13 = $lastpos, !14 = $arrayfinal
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    4     1        ASSIGN                                                       !1, <array>
    5     2        ASSIGN                                                       !2, <array>
    6     3        ASSIGN                                                       !3, <array>
    7     4        ASSIGN                                                       !4, <array>
    9     5        ASSIGN                                                       !5, <array>
   10     6        ASSIGN                                                       !6, ''
   11     7        ASSIGN                                                       !7, 0
   13     8        FETCH_DIM_R                                          ~23     !5, 0
          9        FRAMELESS_ICALL_2                in_array            ~24     ~23, !0
         10        ASSIGN                                                       !8, ~24
   14    11        FETCH_DIM_R                                          ~26     !5, 0
         12        FRAMELESS_ICALL_2                in_array            ~27     ~26, !1
         13        ASSIGN                                                       !9, ~27
   15    14        FETCH_DIM_R                                          ~29     !5, 0
         15        FRAMELESS_ICALL_2                in_array            ~30     ~29, !2
         16        ASSIGN                                                       !10, ~30
   16    17        FETCH_DIM_R                                          ~32     !5, 0
         18        FRAMELESS_ICALL_2                in_array            ~33     ~32, !3
         19        ASSIGN                                                       !11, ~33
   17    20        FETCH_DIM_R                                          ~35     !5, 0
         21        FRAMELESS_ICALL_2                in_array            ~36     ~35, !4
         22        ASSIGN                                                       !12, ~36
   18    23      > JMP                                                          ->120
   19    24    >   FETCH_DIM_R                                          ~38     !5, !7
         25        FRAMELESS_ICALL_2                in_array            ~39     ~38, !0
         26      > JMPZ_EX                                              ~39     ~39, ->29
         27    >   IS_EQUAL                                             ~40     !8, <true>
         28        BOOL                                                 ~39     ~40
         29    > > JMPZ                                                         ~39, ->42
   20    30    >   COUNT                                                ~41     !0
         31        SUB                                                  ~42     ~41, 1
         32        ASSIGN                                                       !13, ~42
   21    33        FETCH_DIM_R                                          ~44     !0, !13
         34        FRAMELESS_ICALL_2                strpos              ~45     !6, ~44
         35        IS_EQUAL                                                     ~45, <false>
         36      > JMPZ                                                         ~46, ->41
   22    37    >   FETCH_DIM_R                                          ~47     !0, !13
         38        CONCAT                                               ~48     !6, ~47
         39        CONCAT                                               ~49     ~48, '+'
         40        ASSIGN                                                       !6, ~49
   19    41    > > JMP                                                          ->43
   25    42    >   ASSIGN                                                       !8, <false>
   27    43    >   FETCH_DIM_R                                          ~52     !5, !7
         44        FRAMELESS_ICALL_2                in_array            ~53     ~52, !1
         45      > JMPZ_EX                                              ~53     ~53, ->48
         46    >   IS_EQUAL                                             ~54     !9, <true>
         47        BOOL                                                 ~53     ~54
         48    > > JMPZ                                                         ~53, ->61
   28    49    >   COUNT                                                ~55     !1
         50        SUB                                                  ~56     ~55, 1
         51        ASSIGN                                                       !13, ~56
   29    52        FETCH_DIM_R                                          ~58     !1, !13
         53        FRAMELESS_ICALL_2                strpos              ~59     !6, ~58
         54        IS_EQUAL                                                     ~59, <false>
         55      > JMPZ                                                         ~60, ->60
   30    56    >   FETCH_DIM_R                                          ~61     !1, !13
         57        CONCAT                                               ~62     !6, ~61
         58        CONCAT                                               ~63     ~62, '+'
         59        ASSIGN                                                       !6, ~63
   27    60    > > JMP                                                          ->62
   33    61    >   ASSIGN                                                       !9, <false>
   35    62    >   FETCH_DIM_R                                          ~66     !5, !7
         63        FRAMELESS_ICALL_2                in_array            ~67     ~66, !2
         64      > JMPZ_EX                                              ~67     ~67, ->67
         65    >   IS_EQUAL                                             ~68     !10, <true>
         66        BOOL                                                 ~67     ~68
         67    > > JMPZ                                                         ~67, ->80
   36    68    >   COUNT                                                ~69     !2
         69        SUB                                                  ~70     ~69, 1
         70        ASSIGN                                                       !13, ~70
   37    71        FETCH_DIM_R                                          ~72     !2, !13
         72        FRAMELESS_ICALL_2                strpos              ~73     !6, ~72
         73        IS_EQUAL                                                     ~73, <false>
         74      > JMPZ                                                         ~74, ->79
   38    75    >   FETCH_DIM_R                                          ~75     !2, !13
         76        CONCAT                                               ~76     !6, ~75
         77        CONCAT                                               ~77     ~76, '+'
         78        ASSIGN                                                       !6, ~77
   35    79    > > JMP                                                          ->81
   41    80    >   ASSIGN                                                       !10, <false>
   43    81    >   FETCH_DIM_R                                          ~80     !5, !7
         82        FRAMELESS_ICALL_2                in_array            ~81     ~80, !3
         83      > JMPZ_EX                                              ~81     ~81, ->86
         84    >   IS_EQUAL                                             ~82     !11, <true>
         85        BOOL                                                 ~81     ~82
         86    > > JMPZ                                                         ~81, ->99
   44    87    >   COUNT                                                ~83     !3
         88        SUB                                                  ~84     ~83, 1
         89        ASSIGN                                                       !13, ~84
   45    90        FETCH_DIM_R                                          ~86     !3, !13
         91        FRAMELESS_ICALL_2                strpos              ~87     !6, ~86
         92        IS_EQUAL                                                     ~87, <false>
         93      > JMPZ                                                         ~88, ->98
   46    94    >   FETCH_DIM_R                                          ~89     !3, !13
         95        CONCAT                                               ~90     !6, ~89
         96        CONCAT                                               ~91     ~90, '+'
         97        ASSIGN                                                       !6, ~91
   43    98    > > JMP                                                          ->100
   49    99    >   ASSIGN                                                       !11, <false>
   51   100    >   FETCH_DIM_R                                          ~94     !5, !7
        101        FRAMELESS_ICALL_2                in_array            ~95     ~94, !4
        102      > JMPZ_EX                                              ~95     ~95, ->105
        103    >   IS_EQUAL                                             ~96     !12, <true>
        104        BOOL                                                 ~95     ~96
        105    > > JMPZ                                                         ~95, ->118
   52   106    >   COUNT                                                ~97     !4
        107        SUB                                                  ~98     ~97, 1
        108        ASSIGN                                                       !13, ~98
   53   109        FETCH_DIM_R                                          ~100    !4, !13
        110        FRAMELESS_ICALL_2                strpos              ~101    !6, ~100
        111        IS_EQUAL                                                     ~101, <false>
        112      > JMPZ                                                         ~102, ->117
   54   113    >   FETCH_DIM_R                                          ~103    !4, !13
        114        CONCAT                                               ~104    !6, ~103
        115        CONCAT                                               ~105    ~104, '+'
        116        ASSIGN                                                       !6, ~105
   51   117    > > JMP                                                          ->119
   57   118    >   ASSIGN                                                       !12, <false>
   59   119    >   PRE_INC                                                      !7
   18   120    >   COUNT                                                ~109    !5
        121        IS_SMALLER                                                   !7, ~109
        122      > JMPNZ                                                        ~110, ->24
   63   123    >   FRAMELESS_ICALL_1                trim                ~111    !6
        124        ASSIGN                                                       !6, ~111
   64   125        INIT_FCALL                                                   'explode'
        126        SEND_VAL                                                     '+'
        127        SEND_VAR                                                     !6
        128        DO_ICALL                                             $113    
        129        ASSIGN                                                       !14, $113
   65   130        INIT_FCALL                                                   'print_r'
        131        SEND_VAR                                                     !14
        132        DO_ICALL                                                     
        133      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
165.82 ms | 2556 KiB | 15 Q