3v4l.org

run code in 500+ PHP versions simultaneously
<?php $content = <<<TEXT ,JAPANESE PRODUCTID1,HONDA PRODUCTID2,TOYOTA PRODUCTID3,NISSAN ,GERMAN PRODUCTID4,BMW PRODUCTID5,AUDI PRODUCTID6,MERCEDES TEXT; function csv_content_parser($content) { foreach (explode("\n", $content) as $line) { yield str_getcsv($line, ","); } } $result = []; $country = null; foreach (csv_content_parser($content) as [$code, $name]) { if (!$code) { $country = $name; continue; } $result[] = compact(['code', 'name', 'country']); } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 23
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 23
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/1Ao2o
function name:  (null)
number of ops:  28
compiled vars:  !0 = $content, !1 = $result, !2 = $country, !3 = $code, !4 = $name
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%2CJAPANESE%0APRODUCTID1%2CHONDA%0APRODUCTID2%2CTOYOTA%0APRODUCTID3%2CNISSAN%0A%2CGERMAN%0APRODUCTID4%2CBMW%0APRODUCTID5%2CAUDI%0APRODUCTID6%2CMERCEDES'
   20     1        ASSIGN                                                       !1, <array>
   21     2        ASSIGN                                                       !2, null
   22     3        INIT_FCALL                                                   'csv_content_parser'
          4        SEND_VAR                                                     !0
          5        DO_FCALL                                          0  $8      
          6      > FE_RESET_R                                           $9      $8, ->23
          7    > > FE_FETCH_R                                                   $9, $10, ->23
          8    >   FETCH_LIST_R                                         $11     $10, 0
          9        ASSIGN                                                       !3, $11
         10        FETCH_LIST_R                                         $13     $10, 1
         11        ASSIGN                                                       !4, $13
         12        FREE                                                         $10
   23    13        BOOL_NOT                                             ~15     !3
         14      > JMPZ                                                         ~15, ->17
   24    15    >   ASSIGN                                                       !2, !4
   25    16      > JMP                                                          ->7
   27    17    >   INIT_FCALL                                                   'compact'
         18        SEND_VAL                                                     <array>
         19        DO_ICALL                                             $18     
         20        ASSIGN_DIM                                                   !1
         21        OP_DATA                                                      $18
   22    22      > JMP                                                          ->7
         23    >   FE_FREE                                                      $9
   29    24        INIT_FCALL                                                   'var_export'
         25        SEND_VAR                                                     !1
         26        DO_ICALL                                                     
         27      > RETURN                                                       1

Function csv_content_parser:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 14
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 14
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 14
filename:       /in/1Ao2o
function name:  csv_content_parser
number of ops:  16
compiled vars:  !0 = $content, !1 = $line
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   RECV                                                 !0      
          1        GENERATOR_CREATE                                             
   15     2        INIT_FCALL                                                   'explode'
          3        SEND_VAL                                                     '%0A'
          4        SEND_VAR                                                     !0
          5        DO_ICALL                                             $2      
          6      > FE_RESET_R                                           $3      $2, ->14
          7    > > FE_FETCH_R                                                   $3, !1, ->14
   16     8    >   INIT_FCALL                                                   'str_getcsv'
          9        SEND_VAR                                                     !1
         10        SEND_VAL                                                     '%2C'
         11        DO_ICALL                                             $4      
         12        YIELD                                                        $4
   15    13      > JMP                                                          ->7
         14    >   FE_FREE                                                      $3
   18    15      > GENERATOR_RETURN                                             

End of function csv_content_parser

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
151.21 ms | 1893 KiB | 18 Q