3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arrays = json_decode('[ { "id": 0, "title": "a title" }, { "id": 1, "title": "another title" }, { "id": 2, "title": "one more title" } ]', true); $array = [ 'id' => 1, 'title' => 'a different title', ]; foreach ($arrays as &$value) { if ($value['id'] === $array['id']) { $value = $array; } } var_dump($value); unset($value); var_dump($arrays);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 7, Position 2 = 14
Branch analysis from position: 7
2 jumps found. (Code = 126) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 13
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/TAfYF
function name:  (null)
number of ops:  23
compiled vars:  !0 = $arrays, !1 = $array, !2 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'json_decode'
          1        SEND_VAL                                                 '%5B%0A++%7B%0A++++++%22id%22%3A+0%2C%0A++++++%22title%22%3A+%22a+title%22%0A++%7D%2C%0A++%7B%0A++++++%22id%22%3A+1%2C%0A++++++%22title%22%3A+%22another+title%22%0A++%7D%2C%0A++%7B%0A++++++%22id%22%3A+2%2C%0A++++++%22title%22%3A+%22one+more+title%22%0A++%7D%0A%5D'
   16     2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $3      
    3     4        ASSIGN                                                   !0, $3
   18     5        ASSIGN                                                   !1, <array>
   23     6      > FE_RESET_RW                                      $6      !0, ->14
          7    > > FE_FETCH_RW                                              $6, !2, ->14
   24     8    >   FETCH_DIM_R                                      ~7      !2, 'id'
          9        FETCH_DIM_R                                      ~8      !1, 'id'
         10        IS_IDENTICAL                                             ~7, ~8
         11      > JMPZ                                                     ~9, ->13
   25    12    >   ASSIGN                                                   !2, !1
   23    13    > > JMP                                                      ->7
         14    >   FE_FREE                                                  $6
   28    15        INIT_FCALL                                               'var_dump'
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                                 
   29    18        UNSET_CV                                                 !2
   30    19        INIT_FCALL                                               'var_dump'
         20        SEND_VAR                                                 !0
         21        DO_ICALL                                                 
         22      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.81 ms | 1395 KiB | 17 Q