3v4l.org

run code in 500+ PHP versions simultaneously
<?php // Simulated file data $data = <<<TAG Hunky Bill's Big Perogie / Pierogi Maker 9 4 10 5 5 1 2 1 TAG; // This allows us to create a stream pointing to a string. // This is only done to match the OP's code $csv_file = 'data://text/plain,'.$data; // We'll store items here temporarily $csv_items = []; if (($fp = fopen($csv_file, 'r'))) { while (!feof($fp)) { $item = fgets($fp); // Sanity check that we received something if (false === $item) { break; } // Trim both sides (unless you have a need for whitespace) $item = trim($item); // If we still have more than just an empty string if ($item) { // Append, optionally with quotes $csv_items[] = '"'.$item.'"'; } } fclose($fp); } // Create final string $csv_string = implode(',', $csv_items); var_dump($csv_string);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 33
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 11
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 18
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 25
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 11
Branch analysis from position: 30
Branch analysis from position: 11
Branch analysis from position: 25
Branch analysis from position: 33
filename:       /in/Chk2M
function name:  (null)
number of ops:  39
compiled vars:  !0 = $data, !1 = $csv_file, !2 = $csv_items, !3 = $fp, !4 = $item, !5 = $csv_string
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                       !0, 'Hunky+Bill%27s+Big+Perogie+%2F+Pierogi+Maker%0A9%0A4%0A10%0A5%0A5%0A1%0A2%0A1'
   18     1        CONCAT                                               ~7      'data%3A%2F%2Ftext%2Fplain%2C', !0
          2        ASSIGN                                                       !1, ~7
   21     3        ASSIGN                                                       !2, <array>
   23     4        INIT_FCALL                                                   'fopen'
          5        SEND_VAR                                                     !1
          6        SEND_VAL                                                     'r'
          7        DO_ICALL                                             $10     
          8        ASSIGN                                               ~11     !3, $10
          9      > JMPZ                                                         ~11, ->33
   24    10    > > JMP                                                          ->25
   26    11    >   INIT_FCALL                                                   'fgets'
         12        SEND_VAR                                                     !3
         13        DO_ICALL                                             $12     
         14        ASSIGN                                                       !4, $12
   29    15        TYPE_CHECK                                        4          !4
         16      > JMPZ                                                         ~14, ->18
   30    17    > > JMP                                                          ->30
   34    18    >   FRAMELESS_ICALL_1                trim                ~15     !4
         19        ASSIGN                                                       !4, ~15
   37    20      > JMPZ                                                         !4, ->25
   39    21    >   CONCAT                                               ~18     '%22', !4
         22        CONCAT                                               ~19     ~18, '%22'
         23        ASSIGN_DIM                                                   !2
         24        OP_DATA                                                      ~19
   24    25    >   INIT_FCALL                                                   'feof'
         26        SEND_VAR                                                     !3
         27        DO_ICALL                                             $20     
         28        BOOL_NOT                                             ~21     $20
         29      > JMPNZ                                                        ~21, ->11
   42    30    >   INIT_FCALL                                                   'fclose'
         31        SEND_VAR                                                     !3
         32        DO_ICALL                                                     
   46    33    >   FRAMELESS_ICALL_2                implode             ~23     '%2C', !2
         34        ASSIGN                                                       !5, ~23
   48    35        INIT_FCALL                                                   'var_dump'
         36        SEND_VAR                                                     !5
         37        DO_ICALL                                                     
         38      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
171 ms | 1994 KiB | 18 Q