3v4l.org

run code in 300+ PHP versions simultaneously
<?php $crlf = chr(13) . chr(10); $cr = chr(13); $delimiter = '|'; // 7 rows, 5th row has CR linebreak inside $lines = [ 'A', 'a', 'C15|C18|C21|C36|C42|C45|C48|C51|C54|C60|C63|C66|C69|C72|C75|C81|C84|C90|C93|C96|C99|C102|C105|C108|C111', '02-DEC-19|02-DEC-19|707403|GUEST|||PPPPPP||||||RR||||RRSSIAN||FFFF|||||+1111-11-11-111|', '02-DEC-19|02-DEC-19|707404|GUEST|SDDDDD|ВВВВВВВВВВВВ|PPPPPP|СССССС|ПППППП||01.01.1111|M|RR|ППППП|"ПППППППП кккк' . $cr . '"|MISSING LINE CONTENTS|', 'FF_FFFF|FF_1', '|1', ]; $csv = implode($crlf, $lines); $filePath = tempnam(sys_get_temp_dir(), 'csv'); file_put_contents($filePath, $csv); $file = new \SplFileObject($filePath, 'r'); $file->setFlags(SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE | SplFileObject::READ_CSV); //ini_set('auto_detect_line_endings', true); $rows = []; while (!$file->eof()) { $row = $file->fgetcsv($delimiter, '"', "\0"); if ($row === null) { print_r("NULL result found though `SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE` flags set.\n"); } else { $rows[] = implode($delimiter, $row); } } if (implode($crlf, $lines) !== implode($crlf, $rows)) { print_r("Error! Expected:\n"); print_r($lines); print_r("Parsed as:\n"); print_r($rows); } else { print_r("Passed."); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
2 jumps found. (Code = 44) Position 1 = 61, Position 2 = 39
Branch analysis from position: 61
2 jumps found. (Code = 43) Position 1 = 71, Position 2 = 84
Branch analysis from position: 71
1 jumps found. (Code = 42) Position 1 = 87
Branch analysis from position: 87
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 84
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 51
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
Branch analysis from position: 51
2 jumps found. (Code = 44) Position 1 = 61, Position 2 = 39
Branch analysis from position: 61
Branch analysis from position: 39
filename:       /in/ga46S
function name:  (null)
number of ops:  88
compiled vars:  !0 = $crlf, !1 = $cr, !2 = $delimiter, !3 = $lines, !4 = $csv, !5 = $filePath, !6 = $file, !7 = $rows, !8 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%0D%0A'
    4     1        ASSIGN                                                   !1, '%0D'
    6     2        ASSIGN                                                   !2, '%7C'
   10     3        INIT_ARRAY                                       ~12     'A'
   11     4        ADD_ARRAY_ELEMENT                                ~12     'a'
   12     5        ADD_ARRAY_ELEMENT                                ~12     'C15%7CC18%7CC21%7CC36%7CC42%7CC45%7CC48%7CC51%7CC54%7CC60%7CC63%7CC66%7CC69%7CC72%7CC75%7CC81%7CC84%7CC90%7CC93%7CC96%7CC99%7CC102%7CC105%7CC108%7CC111'
   13     6        ADD_ARRAY_ELEMENT                                ~12     '02-DEC-19%7C02-DEC-19%7C707403%7CGUEST%7C%7C%7CPPPPPP%7C%7C%7C%7C%7C%7CRR%7C%7C%7C%7CRRSSIAN%7C%7CFFFF%7C%7C%7C%7C%7C%2B1111-11-11-111%7C'
   14     7        CONCAT                                           ~13     '02-DEC-19%7C02-DEC-19%7C707404%7CGUEST%7CSDDDDD%7C%D0%92%D0%92%D0%92%D0%92%D0%92%D0%92%D0%92%D0%92%D0%92%D0%92%D0%92%D0%92%7CPPPPPP%7C%D0%A1%D0%A1%D0%A1%D0%A1%D0%A1%D0%A1%7C%D0%9F%D0%9F%D0%9F%D0%9F%D0%9F%D0%9F%7C%7C01.01.1111%7CM%7CRR%7C%D0%9F%D0%9F%D0%9F%D0%9F%D0%9F%7C%22%D0%9F%D0%9F%D0%9F%D0%9F%D0%9F%D0%9F%D0%9F%D0%9F+%D0%BA%D0%BA%D0%BA%D0%BA', !1
   15     8        CONCAT                                           ~14     ~13, '%22%7CMISSING+LINE+CONTENTS%7C'
          9        ADD_ARRAY_ELEMENT                                ~12     ~14
   16    10        ADD_ARRAY_ELEMENT                                ~12     'FF_FFFF%7CFF_1'
   17    11        ADD_ARRAY_ELEMENT                                ~12     '%7C1'
    9    12        ASSIGN                                                   !3, ~12
   20    13        INIT_FCALL                                               'implode'
         14        SEND_VAR                                                 !0
         15        SEND_VAR                                                 !3
         16        DO_ICALL                                         $16     
         17        ASSIGN                                                   !4, $16
   22    18        INIT_FCALL                                               'tempnam'
         19        INIT_FCALL                                               'sys_get_temp_dir'
         20        DO_ICALL                                         $18     
         21        SEND_VAR                                                 $18
         22        SEND_VAL                                                 'csv'
         23        DO_ICALL                                         $19     
         24        ASSIGN                                                   !5, $19
   23    25        INIT_FCALL                                               'file_put_contents'
         26        SEND_VAR                                                 !5
         27        SEND_VAR                                                 !4
         28        DO_ICALL                                                 
   25    29        NEW                                              $22     'SplFileObject'
         30        SEND_VAR_EX                                              !5
         31        SEND_VAL_EX                                              'r'
         32        DO_FCALL                                      0          
         33        ASSIGN                                                   !6, $22
   26    34        INIT_METHOD_CALL                                         !6, 'setFlags'
         35        SEND_VAL_EX                                              13
         36        DO_FCALL                                      0          
   31    37        ASSIGN                                                   !7, <array>
   32    38      > JMP                                                      ->57
   33    39    >   INIT_METHOD_CALL                                         !6, 'fgetcsv'
         40        SEND_VAR_EX                                              !2
         41        SEND_VAL_EX                                              '%22'
         42        SEND_VAL_EX                                              '%00'
         43        DO_FCALL                                      0  $27     
         44        ASSIGN                                                   !8, $27
   35    45        TYPE_CHECK                                    2          !8
         46      > JMPZ                                                     ~29, ->51
   36    47    >   INIT_FCALL                                               'print_r'
         48        SEND_VAL                                                 'NULL+result+found+though+%60SplFileObject%3A%3ASKIP_EMPTY+%7C+SplFileObject%3A%3ADROP_NEW_LINE%60+flags+set.%0A'
         49        DO_ICALL                                                 
         50      > JMP                                                      ->57
   38    51    >   INIT_FCALL                                               'implode'
         52        SEND_VAR                                                 !2
         53        SEND_VAR                                                 !8
         54        DO_ICALL                                         $32     
         55        ASSIGN_DIM                                               !7
         56        OP_DATA                                                  $32
   32    57    >   INIT_METHOD_CALL                                         !6, 'eof'
         58        DO_FCALL                                      0  $33     
         59        BOOL_NOT                                         ~34     $33
         60      > JMPNZ                                                    ~34, ->39
   42    61    >   INIT_FCALL                                               'implode'
         62        SEND_VAR                                                 !0
         63        SEND_VAR                                                 !3
         64        DO_ICALL                                         $35     
         65        INIT_FCALL                                               'implode'
         66        SEND_VAR                                                 !0
         67        SEND_VAR                                                 !7
         68        DO_ICALL                                         $36     
         69        IS_NOT_IDENTICAL                                         $35, $36
         70      > JMPZ                                                     ~37, ->84
   43    71    >   INIT_FCALL                                               'print_r'
         72        SEND_VAL                                                 'Error%21+Expected%3A%0A'
         73        DO_ICALL                                                 
   44    74        INIT_FCALL                                               'print_r'
         75        SEND_VAR                                                 !3
         76        DO_ICALL                                                 
   45    77        INIT_FCALL                                               'print_r'
         78        SEND_VAL                                                 'Parsed+as%3A%0A'
         79        DO_ICALL                                                 
   46    80        INIT_FCALL                                               'print_r'
         81        SEND_VAR                                                 !7
         82        DO_ICALL                                                 
         83      > JMP                                                      ->87
   48    84    >   INIT_FCALL                                               'print_r'
         85        SEND_VAL                                                 'Passed.'
         86        DO_ICALL                                                 
   49    87    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
180.88 ms | 1404 KiB | 23 Q