3v4l.org

run code in 300+ PHP versions simultaneously
<?php function by_tag($things) { $sorted = array(); foreach ($things as $thing) { $thing['title'] = "new title"; # this works! $thing['size'] = 100; # this doesn't work, it keeps the old value. array_push($sorted, $thing); } return $sorted; } $unsorted = array( array('foo' => 'bar1', 'size' => 1, 'title' => 'changeme1'), array('foo' => 'bar2', 'size' => 2, 'title' => 'changeme2'), array('foo' => 'bar3', 'size' => 3, 'title' => 'changeme3'), array('foo' => 'bar4', 'size' => 4, 'title' => 'changeme4'), array('foo' => 'bar5', 'size' => 5, 'title' => 'changeme5') ); var_dump(by_tag($unsorted));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/piqvU
function name:  (null)
number of ops:  8
compiled vars:  !0 = $unsorted
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ASSIGN                                                   !0, <array>
   20     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'by_tag'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function by_tag:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 13
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 13
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/piqvU
function name:  by_tag
number of ops:  16
compiled vars:  !0 = $things, !1 = $sorted, !2 = $thing
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        ASSIGN                                                   !1, <array>
    4     2      > FE_RESET_R                                       $4      !0, ->13
          3    > > FE_FETCH_R                                               $4, !2, ->13
    5     4    >   ASSIGN_DIM                                               !2, 'title'
          5        OP_DATA                                                  'new+title'
    6     6        ASSIGN_DIM                                               !2, 'size'
          7        OP_DATA                                                  100
    7     8        INIT_FCALL                                               'array_push'
          9        SEND_REF                                                 !1
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                                 
    4    12      > JMP                                                      ->3
         13    >   FE_FREE                                                  $4
    9    14      > RETURN                                                   !1
   10    15*     > RETURN                                                   null

End of function by_tag

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.42 ms | 1398 KiB | 18 Q