3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = array( array( "name" => "photo", "size" => 400 ), array( "name" => "photo", "size" => 100 ), array( "name" => "video", "size" => 6500 ), array( "name" => "video", "size" => 9888 ), array( "name" => "do photography", "size" => 9999 ), array( "name" => "sound", "size" => 1100 ) ); $values = array_unique ( array_column( $array, 'name') ) ; foreach( $values as $value ) { $value = str_replace(' ', '_', $value); ${$value} = array(); //Create an empty array with name like $photo, $video and $sound } foreach( $array as $a ) { $name = $a['name']; $name = str_replace(' ', '_', $name); ${$name}[] = $a; } echo '<pre>'; print_r($photo); print_r($video); print_r($sound); print_r($do_photography);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 17
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 17
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 29
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 29
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
Branch analysis from position: 17
filename:       /in/BH9Y5
function name:  (null)
number of ops:  44
compiled vars:  !0 = $array, !1 = $values, !2 = $value, !3 = $a, !4 = $name, !5 = $photo, !6 = $video, !7 = $sound, !8 = $do_photography
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   30     1        INIT_FCALL                                                   'array_unique'
          2        INIT_FCALL                                                   'array_column'
          3        SEND_VAR                                                     !0
          4        SEND_VAL                                                     'name'
          5        DO_ICALL                                             $10     
          6        SEND_VAR                                                     $10
          7        DO_ICALL                                             $11     
          8        ASSIGN                                                       !1, $11
   32     9      > FE_RESET_R                                           $13     !1, ->17
         10    > > FE_FETCH_R                                                   $13, !2, ->17
   33    11    >   FRAMELESS_ICALL_3                str_replace         ~14     '+', '_'
         12        OP_DATA                                                      !2
         13        ASSIGN                                                       !2, ~14
   34    14        FETCH_W                          local               $16     !2
         15        ASSIGN                                                       $16, <array>
   32    16      > JMP                                                          ->10
         17    >   FE_FREE                                                      $13
   38    18      > FE_RESET_R                                           $18     !0, ->29
         19    > > FE_FETCH_R                                                   $18, !3, ->29
   39    20    >   FETCH_DIM_R                                          ~19     !3, 'name'
         21        ASSIGN                                                       !4, ~19
   40    22        FRAMELESS_ICALL_3                str_replace         ~21     '+', '_'
         23        OP_DATA                                                      !4
         24        ASSIGN                                                       !4, ~21
   41    25        FETCH_W                          local               $23     !4
         26        ASSIGN_DIM                                                   $23
         27        OP_DATA                                                      !3
   38    28      > JMP                                                          ->19
         29    >   FE_FREE                                                      $18
   44    30        ECHO                                                         '%3Cpre%3E'
   45    31        INIT_FCALL                                                   'print_r'
         32        SEND_VAR                                                     !5
         33        DO_ICALL                                                     
   46    34        INIT_FCALL                                                   'print_r'
         35        SEND_VAR                                                     !6
         36        DO_ICALL                                                     
   47    37        INIT_FCALL                                                   'print_r'
         38        SEND_VAR                                                     !7
         39        DO_ICALL                                                     
   48    40        INIT_FCALL                                                   'print_r'
         41        SEND_VAR                                                     !8
         42        DO_ICALL                                                     
         43      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
235.11 ms | 2230 KiB | 17 Q