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); $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 = 30
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 30
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/Vdc2R
function name:  (null)
number of ops:  37
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, ->30
          9    > > FE_FETCH_R                                       ~14     $10, $11, ->30
         10    >   FETCH_LIST_R                                     $12     $11, 'city'
         11        ASSIGN                                                   !3, $12
         12        FREE                                                     $11
         13        ASSIGN                                                   !4, ~14
   39    14        INIT_FCALL                                               'sprintf'
   40    15        SEND_VAL                                                 '%3Coption+data-city%3D%22%25s%22%3E%25s%3C%2Foption%3E'
   41    16        INIT_FCALL                                               'implode'
         17        SEND_VAL                                                 '%2C'
         18        INIT_FCALL                                               'array_column'
         19        SEND_VAR                                                 !3
         20        SEND_VAL                                                 'name'
         21        DO_ICALL                                         $17     
         22        SEND_VAR                                                 $17
         23        DO_ICALL                                         $18     
         24        SEND_VAR                                                 $18
   42    25        SEND_VAR                                                 !4
   39    26        DO_ICALL                                         $19     
         27        ASSIGN_DIM                                               !2
   42    28        OP_DATA                                                  $19
   38    29      > JMP                                                      ->9
         30    >   FE_FREE                                                  $10
   46    31        INIT_FCALL                                               'implode'
         32        SEND_VAL                                                 '%0A'
         33        SEND_VAR                                                 !2
         34        DO_ICALL                                         $20     
         35        ECHO                                                     $20
         36      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.96 ms | 1008 KiB | 17 Q