3v4l.org

run code in 300+ PHP versions simultaneously
<?php $csv = <<<'CSV' name, mail, age, bio john, j@ohn.com, 32, mary, mary@popp.com, 29, jeff, brid@ges.co, 47, "peterson, peter", peter@sson.com, 44, "loves: hobbies puzzles" CSV; $file = fopen('php://temp', 'rw'); var_dump($file); echo "\n"; fwrite($file, $csv); rewind($file); fpassthru($file); rewind($file); echo "\n\n"; function csv($file) { $header = null; while ($row = fgetcsv($file)) { $row = array_map('trim', $row); if ($header) { yield array_combine($header, $row); } else { $header = $row; } } } print_r(iterator_to_array(csv($file)));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/j65it
function name:  (null)
number of ops:  34
compiled vars:  !0 = $csv, !1 = $file
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'name%2C+mail%2C+age%2C+bio%0Ajohn%2C+j%40ohn.com%2C+32%2C+%0Amary%2C+mary%40popp.com%2C+29%2C+%0Ajeff%2C+brid%40ges.co%2C+47%2C+%0A%22peterson%2C+peter%22%2C+peter%40sson.com%2C+44%2C+%22loves%3A%0Ahobbies%0Apuzzles%22'
   13     1        INIT_FCALL                                               'fopen'
          2        SEND_VAL                                                 'php%3A%2F%2Ftemp'
          3        SEND_VAL                                                 'rw'
          4        DO_ICALL                                         $3      
          5        ASSIGN                                                   !1, $3
   14     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                                 
   15     9        ECHO                                                     '%0A'
   17    10        INIT_FCALL                                               'fwrite'
         11        SEND_VAR                                                 !1
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                                 
   18    14        INIT_FCALL                                               'rewind'
         15        SEND_VAR                                                 !1
         16        DO_ICALL                                                 
   20    17        INIT_FCALL                                               'fpassthru'
         18        SEND_VAR                                                 !1
         19        DO_ICALL                                                 
   21    20        INIT_FCALL                                               'rewind'
         21        SEND_VAR                                                 !1
         22        DO_ICALL                                                 
   22    23        ECHO                                                     '%0A%0A'
   37    24        INIT_FCALL                                               'print_r'
         25        INIT_FCALL                                               'iterator_to_array'
         26        INIT_FCALL                                               'csv'
         27        SEND_VAR                                                 !1
         28        DO_FCALL                                      0  $10     
         29        SEND_VAR                                                 $10
         30        DO_ICALL                                         $11     
         31        SEND_VAR                                                 $11
         32        DO_ICALL                                                 
         33      > RETURN                                                   1

Function csv:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 4
Branch analysis from position: 22
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 4
Branch analysis from position: 22
Branch analysis from position: 4
filename:       /in/j65it
function name:  csv
number of ops:  23
compiled vars:  !0 = $file, !1 = $header, !2 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
   25     2        ASSIGN                                                   !1, null
   26     3      > JMP                                                      ->17
   27     4    >   INIT_FCALL                                               'array_map'
          5        SEND_VAL                                                 'trim'
          6        SEND_VAR                                                 !2
          7        DO_ICALL                                         $4      
          8        ASSIGN                                                   !2, $4
   28     9      > JMPZ                                                     !1, ->16
   29    10    >   INIT_FCALL                                               'array_combine'
         11        SEND_VAR                                                 !1
         12        SEND_VAR                                                 !2
         13        DO_ICALL                                         $6      
         14        YIELD                                                    $6
   28    15      > JMP                                                      ->17
   32    16    >   ASSIGN                                                   !1, !2
   26    17    >   INIT_FCALL                                               'fgetcsv'
         18        SEND_VAR                                                 !0
         19        DO_ICALL                                         $9      
         20        ASSIGN                                           ~10     !2, $9
         21      > JMPNZ                                                    ~10, ->4
   35    22    > > GENERATOR_RETURN                                         

End of function csv

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.93 ms | 1477 KiB | 24 Q