3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '{ "world": { "france": { "city": { "city_1": { "name": "paris", "titre": "lorem ipsum" }, "city_2": { "name": "marseille", "titre": "dolor sit amet" } } }, "usa": { "city": { "city_1": { "name": "new york", "titre": "lorem ipsum" }, "city_2": { "name": "los angeles", "titre": "lorem ipsum" }, "city_3": { "name": "portland", "titre": "lorem ipsum" } } } } }'; $data = json_decode($json, true); $scenario = ''; foreach($data['world'] as $country=>$cities) { $cityArray = array(); foreach($cities['city'] as $key=>$values) { $cityArray[] = $values['name']; } $scenario .= '<option value="'.$country.'" data-city="'.implode(',', $cityArray).'">'.$country.'</option>'; } echo $scenario;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 33
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 33
Branch analysis from position: 10
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 20
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 20
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 20
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
filename:       /in/l986m
function name:  (null)
number of ops:  36
compiled vars:  !0 = $json, !1 = $data, !2 = $scenario, !3 = $cities, !4 = $country, !5 = $cityArray, !6 = $values, !7 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%7B%0A%22world%22%3A+%7B%0A++++%22france%22%3A+%7B%0A++++++++%22city%22%3A+%7B%0A++++++++++++%22city_1%22%3A+%7B%0A++++++++++++++++%22name%22%3A+%22paris%22%2C%0A++++++++++++++++%22titre%22%3A+%22lorem+ipsum%22%0A++++++++++++%7D%2C%0A++++++++++++%22city_2%22%3A+%7B%0A++++++++++++++++%22name%22%3A+%22marseille%22%2C%0A++++++++++++++++%22titre%22%3A+%22dolor+sit+amet%22%0A++++++++++++%7D%0A++++++++%7D%0A++++%7D%2C%0A++++%22usa%22%3A+%7B%0A++++++++%22city%22%3A+%7B%0A++++++++++++%22city_1%22%3A+%7B%0A++++++++++++++++%22name%22%3A+%22new+york%22%2C%0A++++++++++++++++%22titre%22%3A+%22lorem+ipsum%22%0A++++++++++++%7D%2C%0A++++++++++++%22city_2%22%3A+%7B%0A++++++++++++++++%22name%22%3A+%22los+angeles%22%2C%0A++++++++++++++++%22titre%22%3A+%22lorem+ipsum%22%0A++++++++++++%7D%2C%0A++++++++++++%22city_3%22%3A+%7B%0A++++++++++++++++%22name%22%3A+%22portland%22%2C%0A++++++++++++++++%22titre%22%3A+%22lorem+ipsum%22%0A++++++++++++%7D%0A++++++++%7D%0A++++%7D%0A%7D%0A%7D'
   36     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $9      
          5        ASSIGN                                                   !1, $9
   37     6        ASSIGN                                                   !2, ''
   38     7        FETCH_DIM_R                                      ~12     !1, 'world'
          8      > FE_RESET_R                                       $13     ~12, ->33
          9    > > FE_FETCH_R                                       ~14     $13, !3, ->33
         10    >   ASSIGN                                                   !4, ~14
   39    11        ASSIGN                                                   !5, <array>
   40    12        FETCH_DIM_R                                      ~17     !3, 'city'
         13      > FE_RESET_R                                       $18     ~17, ->20
         14    > > FE_FETCH_R                                       ~19     $18, !6, ->20
         15    >   ASSIGN                                                   !7, ~19
   41    16        FETCH_DIM_R                                      ~22     !6, 'name'
         17        ASSIGN_DIM                                               !5
         18        OP_DATA                                                  ~22
   40    19      > JMP                                                      ->14
         20    >   FE_FREE                                                  $18
   43    21        CONCAT                                           ~23     '%3Coption+value%3D%22', !4
         22        CONCAT                                           ~24     ~23, '%22+data-city%3D%22'
         23        INIT_FCALL                                               'implode'
         24        SEND_VAL                                                 '%2C'
         25        SEND_VAR                                                 !5
         26        DO_ICALL                                         $25     
         27        CONCAT                                           ~26     ~24, $25
         28        CONCAT                                           ~27     ~26, '%22%3E'
         29        CONCAT                                           ~28     ~27, !4
         30        CONCAT                                           ~29     ~28, '%3C%2Foption%3E'
         31        ASSIGN_OP                                     8          !2, ~29
   38    32      > JMP                                                      ->9
         33    >   FE_FREE                                                  $13
   46    34        ECHO                                                     !2
   47    35      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.2 ms | 1006 KiB | 15 Q