3v4l.org

run code in 300+ PHP versions simultaneously
<?php $links = array( "product.php?shopprodid=1057&variantid=2942" => "https://storksak.com/changing-bags", "index.php?pageid=2" => "https://storksak.com/changing-bags/olivia", "changing-bags/shoulder-bag/emma.html" => "https://storksak.com/changing-bags/emma" ); foreach ($links as $url => $tourl){ $parsed_url = parse_url($url); $query = isset($parsed_url['query']) ? $parsed_url['query'] : ''; parse_str($query,$parts); if (isarray($parts)){ if (isset($parts["shopprodid"]) && isset($parts["variantid"])){ echo 'RewriteCond %{QUERY_STRING} ^shopprodid='.$parts["shopprodid"].'&variantid='.$parts["variantid"].'$'."\n"; echo 'RewriteRule ^product.php$ '.$tourl.' [R=301,L]'."\n"; } elseif (isset($parts["pageid"])){ echo 'RewriteCond %{QUERY_STRING} ^pageid='.$parts["pageid"].'$'."\n"; echo 'RewriteRule ^index.php$ '.$tourl.' [R=301,L]'."\n"; } elseif (isset($parts["shopcatid"])){ echo 'RewriteCond %{QUERY_STRING} ^shopcatid='.$parts["shopcatid"].'$'."\n"; echo 'RewriteRule ^shop.php$ '.$tourl.' [R=301,L]'."\n"; } } else { echo 'RewriteRule ^'.$url.'$ '.$tourl.' [R=301,L]'."\n"; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 72
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 72
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 65
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 = 41
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
1 jumps found. (Code = 42) Position 1 = 71
Branch analysis from position: 71
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 53
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
Branch analysis from position: 53
2 jumps found. (Code = 43) Position 1 = 55, Position 2 = 64
Branch analysis from position: 55
1 jumps found. (Code = 42) Position 1 = 71
Branch analysis from position: 71
Branch analysis from position: 64
Branch analysis from position: 27
Branch analysis from position: 65
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 65
Branch analysis from position: 23
Branch analysis from position: 65
Branch analysis from position: 72
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 72
filename:       /in/tSisU
function name:  (null)
number of ops:  74
compiled vars:  !0 = $links, !1 = $tourl, !2 = $url, !3 = $parsed_url, !4 = $query, !5 = $parts
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   10     1      > FE_RESET_R                                       $7      !0, ->72
          2    > > FE_FETCH_R                                       ~8      $7, !1, ->72
          3    >   ASSIGN                                                   !2, ~8
   11     4        INIT_FCALL                                               'parse_url'
          5        SEND_VAR                                                 !2
          6        DO_ICALL                                         $10     
          7        ASSIGN                                                   !3, $10
   12     8        ISSET_ISEMPTY_DIM_OBJ                         0          !3, 'query'
          9      > JMPZ                                                     ~12, ->13
         10    >   FETCH_DIM_R                                      ~13     !3, 'query'
         11        QM_ASSIGN                                        ~14     ~13
         12      > JMP                                                      ->14
         13    >   QM_ASSIGN                                        ~14     ''
         14    >   ASSIGN                                                   !4, ~14
   14    15        INIT_FCALL                                               'parse_str'
         16        SEND_VAR                                                 !4
         17        SEND_REF                                                 !5
         18        DO_ICALL                                                 
   16    19        INIT_FCALL_BY_NAME                                       'isarray'
         20        SEND_VAR_EX                                              !5
         21        DO_FCALL                                      0  $17     
         22      > JMPZ                                                     $17, ->65
   17    23    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~18     !5, 'shopprodid'
         24      > JMPZ_EX                                          ~18     ~18, ->27
         25    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~19     !5, 'variantid'
         26        BOOL                                             ~18     ~19
         27    > > JMPZ                                                     ~18, ->41
   18    28    >   FETCH_DIM_R                                      ~20     !5, 'shopprodid'
         29        CONCAT                                           ~21     'RewriteCond+%25%7BQUERY_STRING%7D+%5Eshopprodid%3D', ~20
         30        CONCAT                                           ~22     ~21, '%26variantid%3D'
         31        FETCH_DIM_R                                      ~23     !5, 'variantid'
         32        CONCAT                                           ~24     ~22, ~23
         33        CONCAT                                           ~25     ~24, '%24'
         34        CONCAT                                           ~26     ~25, '%0A'
         35        ECHO                                                     ~26
   19    36        CONCAT                                           ~27     'RewriteRule+%5Eproduct.php%24+', !1
         37        CONCAT                                           ~28     ~27, '+%5BR%3D301%2CL%5D'
         38        CONCAT                                           ~29     ~28, '%0A'
         39        ECHO                                                     ~29
         40      > JMP                                                      ->64
   20    41    >   ISSET_ISEMPTY_DIM_OBJ                         0          !5, 'pageid'
         42      > JMPZ                                                     ~30, ->53
   21    43    >   FETCH_DIM_R                                      ~31     !5, 'pageid'
         44        CONCAT                                           ~32     'RewriteCond+%25%7BQUERY_STRING%7D+%5Epageid%3D', ~31
         45        CONCAT                                           ~33     ~32, '%24'
         46        CONCAT                                           ~34     ~33, '%0A'
         47        ECHO                                                     ~34
   22    48        CONCAT                                           ~35     'RewriteRule+%5Eindex.php%24+', !1
         49        CONCAT                                           ~36     ~35, '+%5BR%3D301%2CL%5D'
         50        CONCAT                                           ~37     ~36, '%0A'
         51        ECHO                                                     ~37
         52      > JMP                                                      ->64
   23    53    >   ISSET_ISEMPTY_DIM_OBJ                         0          !5, 'shopcatid'
         54      > JMPZ                                                     ~38, ->64
   24    55    >   FETCH_DIM_R                                      ~39     !5, 'shopcatid'
         56        CONCAT                                           ~40     'RewriteCond+%25%7BQUERY_STRING%7D+%5Eshopcatid%3D', ~39
         57        CONCAT                                           ~41     ~40, '%24'
         58        CONCAT                                           ~42     ~41, '%0A'
         59        ECHO                                                     ~42
   25    60        CONCAT                                           ~43     'RewriteRule+%5Eshop.php%24+', !1
         61        CONCAT                                           ~44     ~43, '+%5BR%3D301%2CL%5D'
         62        CONCAT                                           ~45     ~44, '%0A'
         63        ECHO                                                     ~45
         64    > > JMP                                                      ->71
   28    65    >   CONCAT                                           ~46     'RewriteRule+%5E', !2
         66        CONCAT                                           ~47     ~46, '%24+'
         67        CONCAT                                           ~48     ~47, !1
         68        CONCAT                                           ~49     ~48, '+%5BR%3D301%2CL%5D'
         69        CONCAT                                           ~50     ~49, '%0A'
         70        ECHO                                                     ~50
   10    71    > > JMP                                                      ->2
         72    >   FE_FREE                                                  $7
   30    73      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.43 ms | 1404 KiB | 17 Q