3v4l.org

run code in 500+ 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); $options = []; foreach ($data['world'] as $country => ['city' => $cities]) { $options[] = sprintf( '<option data-city="%s">%s</option>', implode(',', array_column($cities, 'name')), $country ); } echo implode("\n", $options);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 27
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 27
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/Vdc2R
function name:  (null)
number of ops:  31
compiled vars:  !0 = $json, !1 = $data, !2 = $options, !3 = $cities, !4 = $country
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                                             $6      
          5        ASSIGN                                                       !1, $6
   37     6        ASSIGN                                                       !2, <array>
   38     7        FETCH_DIM_R                                          ~9      !1, 'world'
          8      > FE_RESET_R                                           $10     ~9, ->27
          9    > > FE_FETCH_R                                           ~14     $10, $11, ->27
         10    >   FETCH_LIST_R                                         $12     $11, 'city'
         11        ASSIGN                                                       !3, $12
         12        FREE                                                         $11
         13        ASSIGN                                                       !4, ~14
   41    14        INIT_FCALL                                                   'array_column'
         15        SEND_VAR                                                     !3
         16        SEND_VAL                                                     'name'
         17        DO_ICALL                                             $17     
         18        FRAMELESS_ICALL_2                implode             ~18     '%2C', $17
   42    19        ROPE_INIT                                         5  ~20     '%3Coption+data-city%3D%22'
         20        ROPE_ADD                                          1  ~20     ~20, ~18
         21        ROPE_ADD                                          2  ~20     ~20, '%22%3E'
         22        ROPE_ADD                                          3  ~20     ~20, !4
         23        ROPE_END                                          4  ~19     ~20, '%3C%2Foption%3E'
   39    24        ASSIGN_DIM                                                   !2
   42    25        OP_DATA                                                      ~19
   38    26      > JMP                                                          ->9
         27    >   FE_FREE                                                      $10
   46    28        FRAMELESS_ICALL_2                implode             ~23     '%0A', !2
         29        ECHO                                                         ~23
         30      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
172.27 ms | 1880 KiB | 15 Q