3v4l.org

run code in 300+ PHP versions simultaneously
<?php $stats['page_fans_city'] = [ 'Belo Horizonte, Minas Gerais, Brazil' => 100, 'Lima, Peru' => 100, 'Bangkok, Thailand' => 100, 'Beja, Portugal' => 100, ]; $available_cities = array( 'Lisbon, Lisboa, Portugal', 'Braga, Portugal', 'Porto, Portugal', 'Coimbra, Portugal', 'Faro, Portugal', 'Aveiro, Portugal', 'Oeiras, Portugal' ); $replace_cities = array( 'Lima, Peru', 'Istanbul, Turkey', 'Bangkok, Thailand', 'Hanoi, Ha Noi, Vietnam', 'Dhaka, Bangladesh', 'São Paulo, Brazil', 'Rio de Janeiro, Brazil', 'Belo Horizonte, Minas Gerais, Brazil', 'Recife, Pernambuco, Brazil' ); // HACK FOR CITY NAMES :) foreach ($stats['page_fans_city'] as $city => $value) { if (in_array($city, $replace_cities)) { //unset($replace_cities[$city]); $available_city = array_pop($available_cities); while (array_key_exists($available_city, $stats['page_fans_city'])) { if (count($available_cities) <= 0) { echo 'No more available cities'; break; } $available_city = array_pop($available_cities); $stats['page_fans_city'][$available_city] = $value; echo "\nNova: " . $available_city . "\n"; } unset($stats['page_fans_city'][$city]); echo "\nAntiga: " . $city . "\n"; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 42
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 42
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 41
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 18
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 18
Branch analysis from position: 36
Branch analysis from position: 18
Branch analysis from position: 41
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
filename:       /in/4dh4Y
function name:  (null)
number of ops:  44
compiled vars:  !0 = $stats, !1 = $available_cities, !2 = $replace_cities, !3 = $value, !4 = $city, !5 = $available_city
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN_DIM                                               !0, 'page_fans_city'
    4     1        OP_DATA                                                  <array>
   10     2        ASSIGN                                                   !1, <array>
   20     3        ASSIGN                                                   !2, <array>
   33     4        FETCH_DIM_R                                      ~9      !0, 'page_fans_city'
          5      > FE_RESET_R                                       $10     ~9, ->42
          6    > > FE_FETCH_R                                       ~11     $10, !3, ->42
          7    >   ASSIGN                                                   !4, ~11
   35     8        INIT_FCALL                                               'in_array'
          9        SEND_VAR                                                 !4
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                         $13     
         12      > JMPZ                                                     $13, ->41
   37    13    >   INIT_FCALL                                               'array_pop'
         14        SEND_REF                                                 !1
         15        DO_ICALL                                         $14     
         16        ASSIGN                                                   !5, $14
   39    17      > JMP                                                      ->33
   41    18    >   COUNT                                            ~16     !1
         19        IS_SMALLER_OR_EQUAL                                      ~16, 0
         20      > JMPZ                                                     ~17, ->23
   42    21    >   ECHO                                                     'No+more+available+cities'
   43    22      > JMP                                                      ->36
   46    23    >   INIT_FCALL                                               'array_pop'
         24        SEND_REF                                                 !1
         25        DO_ICALL                                         $18     
         26        ASSIGN                                                   !5, $18
   48    27        FETCH_DIM_W                                      $20     !0, 'page_fans_city'
         28        ASSIGN_DIM                                               $20, !5
         29        OP_DATA                                                  !3
   49    30        CONCAT                                           ~22     '%0ANova%3A+', !5
         31        CONCAT                                           ~23     ~22, '%0A'
         32        ECHO                                                     ~23
   39    33    >   FETCH_DIM_R                                      ~24     !0, 'page_fans_city'
         34        ARRAY_KEY_EXISTS                                         !5, ~24
         35      > JMPNZ                                                    ~25, ->18
   52    36    >   FETCH_DIM_UNSET                                  $26     !0, 'page_fans_city'
         37        UNSET_DIM                                                $26, !4
   54    38        CONCAT                                           ~27     '%0AAntiga%3A+', !4
         39        CONCAT                                           ~28     ~27, '%0A'
         40        ECHO                                                     ~28
   33    41    > > JMP                                                      ->6
         42    >   FE_FREE                                                  $10
   59    43      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
237.04 ms | 1400 KiB | 17 Q