3v4l.org

run code in 300+ PHP versions simultaneously
<?php $Ucountries = ["Uganda", "Ukraine", "United Arab Emirates (UAE)", "United Kingdom (UK)", "United States of America (USA)", "Uruguay", "Uzbekistan"]; $Mcountries = ["Macedonia (FYROM)", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Montenegro", "Morocco", "Mozambique", "Myanmar (Burma)"]; $str = "countries_mexico_mexico_city"; //$str = "countries_united_states_ohio"; $str = str_replace("countries_", "", $str); // Copy array needed to $CountryList $CountryList = ${strtoupper(substr($str,0,1)). "countries"}; $countryarr = array(); $arr = explode("_", $str); Foreach($arr as $val){ Foreach($CountryList as $item){ If(stripos($item, $val) !== false){ If(!in_array($val, $countryarr)){ $countryarr[] = $val; } } } } $country = implode(" ", $countryarr); $state_city = preg_replace("/" . implode("_",$countryarr) . "/", "", $str,1); $state_city = trim(str_replace("_", " ", $state_city)); Echo $country . "\n" . $state_city;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 27, Position 2 = 47
Branch analysis from position: 27
2 jumps found. (Code = 78) Position 1 = 28, Position 2 = 47
Branch analysis from position: 28
2 jumps found. (Code = 77) Position 1 = 29, Position 2 = 45
Branch analysis from position: 29
2 jumps found. (Code = 78) Position 1 = 30, Position 2 = 45
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 44
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 44
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 44
Branch analysis from position: 44
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 45
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
filename:       /in/POMPT
function name:  (null)
number of ops:  79
compiled vars:  !0 = $Ucountries, !1 = $Mcountries, !2 = $str, !3 = $CountryList, !4 = $countryarr, !5 = $arr, !6 = $val, !7 = $item, !8 = $country, !9 = $state_city
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   11     1        ASSIGN                                                   !1, <array>
   31     2        ASSIGN                                                   !2, 'countries_mexico_mexico_city'
   33     3        INIT_FCALL                                               'str_replace'
          4        SEND_VAL                                                 'countries_'
          5        SEND_VAL                                                 ''
          6        SEND_VAR                                                 !2
          7        DO_ICALL                                         $13     
          8        ASSIGN                                                   !2, $13
   36     9        INIT_FCALL                                               'strtoupper'
         10        INIT_FCALL                                               'substr'
         11        SEND_VAR                                                 !2
         12        SEND_VAL                                                 0
         13        SEND_VAL                                                 1
         14        DO_ICALL                                         $15     
         15        SEND_VAR                                                 $15
         16        DO_ICALL                                         $16     
         17        CONCAT                                           ~17     $16, 'countries'
         18        FETCH_R                      local               ~18     ~17
         19        ASSIGN                                                   !3, ~18
   38    20        ASSIGN                                                   !4, <array>
   39    21        INIT_FCALL                                               'explode'
         22        SEND_VAL                                                 '_'
         23        SEND_VAR                                                 !2
         24        DO_ICALL                                         $21     
         25        ASSIGN                                                   !5, $21
   41    26      > FE_RESET_R                                       $23     !5, ->47
         27    > > FE_FETCH_R                                               $23, !6, ->47
   42    28    > > FE_RESET_R                                       $24     !3, ->45
         29    > > FE_FETCH_R                                               $24, !7, ->45
   43    30    >   INIT_FCALL                                               'stripos'
         31        SEND_VAR                                                 !7
         32        SEND_VAR                                                 !6
         33        DO_ICALL                                         $25     
         34        TYPE_CHECK                                  1018          $25
         35      > JMPZ                                                     ~26, ->44
   44    36    >   INIT_FCALL                                               'in_array'
         37        SEND_VAR                                                 !6
         38        SEND_VAR                                                 !4
         39        DO_ICALL                                         $27     
         40        BOOL_NOT                                         ~28     $27
         41      > JMPZ                                                     ~28, ->44
   45    42    >   ASSIGN_DIM                                               !4
         43        OP_DATA                                                  !6
   42    44    > > JMP                                                      ->29
         45    >   FE_FREE                                                  $24
   41    46      > JMP                                                      ->27
         47    >   FE_FREE                                                  $23
   51    48        INIT_FCALL                                               'implode'
         49        SEND_VAL                                                 '+'
         50        SEND_VAR                                                 !4
         51        DO_ICALL                                         $30     
         52        ASSIGN                                                   !8, $30
   52    53        INIT_FCALL                                               'preg_replace'
         54        INIT_FCALL                                               'implode'
         55        SEND_VAL                                                 '_'
         56        SEND_VAR                                                 !4
         57        DO_ICALL                                         $32     
         58        CONCAT                                           ~33     '%2F', $32
         59        CONCAT                                           ~34     ~33, '%2F'
         60        SEND_VAL                                                 ~34
         61        SEND_VAL                                                 ''
         62        SEND_VAR                                                 !2
         63        SEND_VAL                                                 1
         64        DO_ICALL                                         $35     
         65        ASSIGN                                                   !9, $35
   53    66        INIT_FCALL                                               'trim'
         67        INIT_FCALL                                               'str_replace'
         68        SEND_VAL                                                 '_'
         69        SEND_VAL                                                 '+'
         70        SEND_VAR                                                 !9
         71        DO_ICALL                                         $37     
         72        SEND_VAR                                                 $37
         73        DO_ICALL                                         $38     
         74        ASSIGN                                                   !9, $38
   55    75        CONCAT                                           ~40     !8, '%0A'
         76        CONCAT                                           ~41     ~40, !9
         77        ECHO                                                     ~41
         78      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
133.26 ms | 1467 KiB | 22 Q