3v4l.org

run code in 300+ PHP versions simultaneously
<?php $country_ids = range(1,5); $result['fields'][0]['field_type'] = "countries"; foreach ($country_ids as $id) { $result['fields'][0]['field_value'][] = ["country_id" => $id, "match_type" => "exact"]; } var_export($result); echo "\n---\n"; echo json_encode($result, JSON_PRETTY_PRINT); // this resembles your posted data
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 19
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 19
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/AHCoA
function name:  (null)
number of ops:  30
compiled vars:  !0 = $country_ids, !1 = $result, !2 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 1
          2        SEND_VAL                                                 5
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !0, $3
    3     5        FETCH_DIM_W                                      $5      !1, 'fields'
          6        FETCH_DIM_W                                      $6      $5, 0
          7        ASSIGN_DIM                                               $6, 'field_type'
          8        OP_DATA                                                  'countries'
    4     9      > FE_RESET_R                                       $8      !0, ->19
         10    > > FE_FETCH_R                                               $8, !2, ->19
    5    11    >   INIT_ARRAY                                       ~13     !2, 'country_id'
         12        ADD_ARRAY_ELEMENT                                ~13     'exact', 'match_type'
         13        FETCH_DIM_W                                      $9      !1, 'fields'
         14        FETCH_DIM_W                                      $10     $9, 0
         15        FETCH_DIM_W                                      $11     $10, 'field_value'
         16        ASSIGN_DIM                                               $11
         17        OP_DATA                                                  ~13
    4    18      > JMP                                                      ->10
         19    >   FE_FREE                                                  $8
    8    20        INIT_FCALL                                               'var_export'
         21        SEND_VAR                                                 !1
         22        DO_ICALL                                                 
    9    23        ECHO                                                     '%0A---%0A'
   10    24        INIT_FCALL                                               'json_encode'
         25        SEND_VAR                                                 !1
         26        SEND_VAL                                                 128
         27        DO_ICALL                                         $15     
         28        ECHO                                                     $15
         29      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
179.99 ms | 1407 KiB | 19 Q