3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arrAccesories = '[{"value":"Charger"},{"value":"Bag Only"},{"value":"Data Privacy Filter"},{"value":"Headset"}]'; $arrAccesories = json_decode($arrAccesories); $accessoriesID = [ "Charger" => "11043", "Mouse" => "11044", "Bag With Strap" => "11045", "Bag Only" => "11046", "Cable Lock" => "11047", "Data Privacy Filter" => "11048", "Numeric Lock" => "11049", "Headset" => "11050", "HDMI to VGA adapter" => "11051", "LAN Adapter" => "12223", "Others (Please include in the remarks box below.)" => "11052" ]; $default = $accessoriesID['Others (Please include in the remarks box below.)']; foreach ($arrAccesories as $row) { $row->id = $accessoriesId[$row->value] ?? $default; } echo json_encode($arrAccesories);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 17
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/QJObG
function name:  (null)
number of ops:  23
compiled vars:  !0 = $arrAccesories, !1 = $accessoriesID, !2 = $default, !3 = $row, !4 = $accessoriesId
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%5B%7B%22value%22%3A%22Charger%22%7D%2C%7B%22value%22%3A%22Bag+Only%22%7D%2C%7B%22value%22%3A%22Data+Privacy+Filter%22%7D%2C%7B%22value%22%3A%22Headset%22%7D%5D'
    4     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $6      
          4        ASSIGN                                                   !0, $6
    6     5        ASSIGN                                                   !1, <array>
   19     6        FETCH_DIM_R                                      ~9      !1, 'Others+%28Please+include+in+the+remarks+box+below.%29'
          7        ASSIGN                                                   !2, ~9
   21     8      > FE_RESET_R                                       $11     !0, ->17
          9    > > FE_FETCH_R                                               $11, !3, ->17
   22    10    >   FETCH_OBJ_R                                      ~13     !3, 'value'
         11        FETCH_DIM_IS                                     ~14     !4, ~13
         12        COALESCE                                         ~15     ~14
         13        QM_ASSIGN                                        ~15     !2
         14        ASSIGN_OBJ                                               !3, 'id'
         15        OP_DATA                                                  ~15
   21    16      > JMP                                                      ->9
         17    >   FE_FREE                                                  $11
   25    18        INIT_FCALL                                               'json_encode'
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                         $16     
         21        ECHO                                                     $16
         22      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.61 ms | 1006 KiB | 15 Q