3v4l.org

run code in 300+ 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 = 20
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 20
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 20
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 35
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 35
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
Branch analysis from position: 20
filename:       /in/BH9Y5
function name:  (null)
number of ops:  50
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, ->20
         10    > > FE_FETCH_R                                               $13, !2, ->20
   33    11    >   INIT_FCALL                                               'str_replace'
         12        SEND_VAL                                                 '+'
         13        SEND_VAL                                                 '_'
         14        SEND_VAR                                                 !2
         15        DO_ICALL                                         $14     
         16        ASSIGN                                                   !2, $14
   34    17        FETCH_W                      local               $16     !2
         18        ASSIGN                                                   $16, <array>
   32    19      > JMP                                                      ->10
         20    >   FE_FREE                                                  $13
   38    21      > FE_RESET_R                                       $18     !0, ->35
         22    > > FE_FETCH_R                                               $18, !3, ->35
   39    23    >   FETCH_DIM_R                                      ~19     !3, 'name'
         24        ASSIGN                                                   !4, ~19
   40    25        INIT_FCALL                                               'str_replace'
         26        SEND_VAL                                                 '+'
         27        SEND_VAL                                                 '_'
         28        SEND_VAR                                                 !4
         29        DO_ICALL                                         $21     
         30        ASSIGN                                                   !4, $21
   41    31        FETCH_W                      local               $23     !4
         32        ASSIGN_DIM                                               $23
         33        OP_DATA                                                  !3
   38    34      > JMP                                                      ->22
         35    >   FE_FREE                                                  $18
   44    36        ECHO                                                     '%3Cpre%3E'
   45    37        INIT_FCALL                                               'print_r'
         38        SEND_VAR                                                 !5
         39        DO_ICALL                                                 
   46    40        INIT_FCALL                                               'print_r'
         41        SEND_VAR                                                 !6
         42        DO_ICALL                                                 
   47    43        INIT_FCALL                                               'print_r'
         44        SEND_VAR                                                 !7
         45        DO_ICALL                                                 
   48    46        INIT_FCALL                                               'print_r'
         47        SEND_VAR                                                 !8
         48        DO_ICALL                                                 
         49      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.15 ms | 1010 KiB | 17 Q