3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = <<<EOD http://localhost:8000/search/fa?q=sth http://localhost:8000/search?q=sth http://localhost:8000/search http://localhost:8000/search/fa EOD; preg_match_all('/^(.*?)\/(\w{2,})(?:\?(.*?)|)$/mis',$str,$p); echo '<pre/>'; $final_array = array(); $i = 0; foreach($p[1] as $myP){ if(!($p[2][$i] == 'fa' || $p[2][$i] == 'en')){ $p[2][$i] = $p[2][$i].'/'.'en'; } $final_array[$i] = $myP.'/'.$p[2][$i]; $i++; } var_dump($final_array);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 37
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 37
Branch analysis from position: 12
2 jumps found. (Code = 47) Position 1 = 16, Position 2 = 20
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 29
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 29
Branch analysis from position: 20
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
filename:       /in/u9hoM
function name:  (null)
number of ops:  42
compiled vars:  !0 = $str, !1 = $p, !2 = $final_array, !3 = $i, !4 = $myP
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'http%3A%2F%2Flocalhost%3A8000%2Fsearch%2Ffa%3Fq%3Dsth%0A%0Ahttp%3A%2F%2Flocalhost%3A8000%2Fsearch%3Fq%3Dsth%0A%0Ahttp%3A%2F%2Flocalhost%3A8000%2Fsearch%0A%0Ahttp%3A%2F%2Flocalhost%3A8000%2Fsearch%2Ffa%0A'
   12     1        INIT_FCALL                                               'preg_match_all'
          2        SEND_VAL                                                 '%2F%5E%28.%2A%3F%29%5C%2F%28%5Cw%7B2%2C%7D%29%28%3F%3A%5C%3F%28.%2A%3F%29%7C%29%24%2Fmis'
          3        SEND_VAR                                                 !0
          4        SEND_REF                                                 !1
          5        DO_ICALL                                                 
   13     6        ECHO                                                     '%3Cpre%2F%3E'
   14     7        ASSIGN                                                   !2, <array>
   15     8        ASSIGN                                                   !3, 0
   16     9        FETCH_DIM_R                                      ~9      !1, 1
         10      > FE_RESET_R                                       $10     ~9, ->37
         11    > > FE_FETCH_R                                               $10, !4, ->37
   17    12    >   FETCH_DIM_R                                      ~11     !1, 2
         13        FETCH_DIM_R                                      ~12     ~11, !3
         14        IS_EQUAL                                         ~13     ~12, 'fa'
         15      > JMPNZ_EX                                         ~13     ~13, ->20
         16    >   FETCH_DIM_R                                      ~14     !1, 2
         17        FETCH_DIM_R                                      ~15     ~14, !3
         18        IS_EQUAL                                         ~16     ~15, 'en'
         19        BOOL                                             ~13     ~16
         20    >   BOOL_NOT                                         ~17     ~13
         21      > JMPZ                                                     ~17, ->29
   18    22    >   FETCH_DIM_R                                      ~20     !1, 2
         23        FETCH_DIM_R                                      ~21     ~20, !3
         24        CONCAT                                           ~22     ~21, '%2F'
         25        CONCAT                                           ~23     ~22, 'en'
         26        FETCH_DIM_W                                      $18     !1, 2
         27        ASSIGN_DIM                                               $18, !3
         28        OP_DATA                                                  ~23
   20    29    >   CONCAT                                           ~25     !4, '%2F'
         30        FETCH_DIM_R                                      ~26     !1, 2
         31        FETCH_DIM_R                                      ~27     ~26, !3
         32        CONCAT                                           ~28     ~25, ~27
         33        ASSIGN_DIM                                               !2, !3
         34        OP_DATA                                                  ~28
   21    35        PRE_INC                                                  !3
   16    36      > JMP                                                      ->11
         37    >   FE_FREE                                                  $10
   25    38        INIT_FCALL                                               'var_dump'
         39        SEND_VAR                                                 !2
         40        DO_ICALL                                                 
         41      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.16 ms | 1400 KiB | 17 Q