3v4l.org

run code in 300+ PHP versions simultaneously
<?php function associative_array_from_csv($csv) { $rows = array_map('str_getcsv', $csv); $header = array_shift($rows); $array = array(); foreach($rows as $data) { $array[] = array_combine($header, $data); } return $array; } $colors = associative_array_from_csv(array( 'ID,COLOR', '1,Red', '2,Green ', '3,Blue' )); var_dump($colors[0]['ID']);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HTcTI
function name:  (null)
number of ops:  10
compiled vars:  !0 = $colors
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_FCALL                                               'associative_array_from_csv'
   16     1        SEND_VAL                                                 <array>
   15     2        DO_FCALL                                      0  $1      
          3        ASSIGN                                                   !0, $1
   24     4        INIT_FCALL                                               'var_dump'
          5        FETCH_DIM_R                                      ~3      !0, 0
          6        FETCH_DIM_R                                      ~4      ~3, 'ID'
          7        SEND_VAL                                                 ~4
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function associative_array_from_csv:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 20
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 20
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/HTcTI
function name:  associative_array_from_csv
number of ops:  23
compiled vars:  !0 = $csv, !1 = $rows, !2 = $header, !3 = $array, !4 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'array_map'
          2        SEND_VAL                                                 'str_getcsv'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !1, $5
    5     6        INIT_FCALL                                               'array_shift'
          7        SEND_REF                                                 !1
          8        DO_ICALL                                         $7      
          9        ASSIGN                                                   !2, $7
    6    10        ASSIGN                                                   !3, <array>
    8    11      > FE_RESET_R                                       $10     !1, ->20
         12    > > FE_FETCH_R                                               $10, !4, ->20
    9    13    >   INIT_FCALL                                               'array_combine'
         14        SEND_VAR                                                 !2
         15        SEND_VAR                                                 !4
         16        DO_ICALL                                         $12     
         17        ASSIGN_DIM                                               !3
         18        OP_DATA                                                  $12
    8    19      > JMP                                                      ->12
         20    >   FE_FREE                                                  $10
   12    21      > RETURN                                                   !3
   13    22*     > RETURN                                                   null

End of function associative_array_from_csv

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.18 ms | 1017 KiB | 18 Q