3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getCURL($url){ $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); return response; } class CSVParser { private $fsArrayColNames; private $fsArrayExtraCols; private $faArrayRecords; private $faArrayExtraRecords; public function getColTitles($includeExtra, &$colCount) { $result[] = $fsArrayColNames; $colCount = count($fsArrayColNames); if ($includeExtra){ array_merge($result,$fsArrayExtraCols); $colCount = $colCount + count($fsArrayExtraCols); } return result; } public function addExtraCols($namesArray){ array_merge($fsArrayExtraCols,$namesArray); $extraCount = count($namesArray); $cnt = count($faArrayExtraRecords); $append = array_fill(0,$cnt,""); for ($i0 = 0; $i0 < $cnt; ++$i0) { array_merge($faArrayExtraRecords[$i0],$append); } } public function getRowCount() { return count($faArrayRecords); } public function getOrSetValue($recordID, $col, $value, $isExtra, $isSet){ if ($isExtra){ if ($isSet) { $faArrayExtraRecords[$recordID][$col]=$value; } else { return $faArrayExtraRecords[$recordID][$col]; } } else { if ($isSet) { $faArrayRecords[$recordID][$col]=$value; } else { return $faArrayRecords[$recordID][$col]; } } } public function parseCSV($source){ $lines = explode($source,"\n"); $once = false; $count = 0; foreach($lines as $line) { $lineArray = explode($line,","); if (once) { array_merge( $faArrayRecords[$count], $lineArray ); } else { $fsArrayColNames = $lineArray; $once = true; } $count = $count++; } } public function parseFromURL($url) { return $this->parseCSV(getCURL($url)); } } $p = new CSVParser(); $url="http://pastebin.com/raw.php?i=vu81DjnS"; $p->parseFromURL($url);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/90XUM
function name:  (null)
number of ops:  8
compiled vars:  !0 = $p, !1 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  103     0  E >   NEW                                              $2      'CSVParser'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
  104     3        ASSIGN                                                   !1, 'http%3A%2F%2Fpastebin.com%2Fraw.php%3Fi%3Dvu81DjnS'
  105     4        INIT_METHOD_CALL                                         !0, 'parseFromURL'
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0          
          7      > RETURN                                                   1

Function getcurl:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/90XUM
function name:  getCURL
number of ops:  21
compiled vars:  !0 = $url, !1 = $ch, !2 = $response
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        INIT_FCALL_BY_NAME                                       'curl_init'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $3      
          4        ASSIGN                                                   !1, $3
    6     5        INIT_FCALL_BY_NAME                                       'curl_setopt'
          6        SEND_VAR_EX                                              !1
          7        FETCH_CONSTANT                                   ~5      'CURLOPT_RETURNTRANSFER'
          8        SEND_VAL_EX                                              ~5
          9        SEND_VAL_EX                                              <true>
         10        DO_FCALL                                      0          
    9    11        INIT_FCALL_BY_NAME                                       'curl_exec'
         12        SEND_VAR_EX                                              !1
         13        DO_FCALL                                      0  $7      
         14        ASSIGN                                                   !2, $7
   10    15        INIT_FCALL_BY_NAME                                       'curl_close'
         16        SEND_VAR_EX                                              !1
         17        DO_FCALL                                      0          
   11    18        FETCH_CONSTANT                                   ~10     'response'
         19      > RETURN                                                   ~10
   12    20*     > RETURN                                                   null

End of function getcurl

Class CSVParser:
Function getcoltitles:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 14
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/90XUM
function name:  getColTitles
number of ops:  17
compiled vars:  !0 = $includeExtra, !1 = $colCount, !2 = $result, !3 = $fsArrayColNames, !4 = $fsArrayExtraCols
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   24     2        ASSIGN_DIM                                               !2
          3        OP_DATA                                                  !3
   26     4        COUNT                                            ~6      !3
          5        ASSIGN                                                   !1, ~6
   28     6      > JMPZ                                                     !0, ->14
   29     7    >   INIT_FCALL                                               'array_merge'
          8        SEND_VAR                                                 !2
          9        SEND_VAR                                                 !4
         10        DO_ICALL                                                 
   30    11        COUNT                                            ~9      !4
         12        ADD                                              ~10     !1, ~9
         13        ASSIGN                                                   !1, ~10
   33    14    >   FETCH_CONSTANT                                   ~12     'result'
         15      > RETURN                                                   ~12
   34    16*     > RETURN                                                   null

End of function getcoltitles

Function addextracols:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 17
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 17
Branch analysis from position: 25
Branch analysis from position: 17
filename:       /in/90XUM
function name:  addExtraCols
number of ops:  26
compiled vars:  !0 = $namesArray, !1 = $fsArrayExtraCols, !2 = $extraCount, !3 = $cnt, !4 = $faArrayExtraRecords, !5 = $append, !6 = $i0
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   RECV                                             !0      
   37     1        INIT_FCALL                                               'array_merge'
          2        SEND_VAR                                                 !1
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                                 
   38     5        COUNT                                            ~8      !0
          6        ASSIGN                                                   !2, ~8
   40     7        COUNT                                            ~10     !4
          8        ASSIGN                                                   !3, ~10
   42     9        INIT_FCALL                                               'array_fill'
         10        SEND_VAL                                                 0
         11        SEND_VAR                                                 !3
         12        SEND_VAL                                                 ''
         13        DO_ICALL                                         $12     
         14        ASSIGN                                                   !5, $12
   44    15        ASSIGN                                                   !6, 0
         16      > JMP                                                      ->23
   45    17    >   INIT_FCALL                                               'array_merge'
         18        FETCH_DIM_R                                      ~15     !4, !6
         19        SEND_VAL                                                 ~15
         20        SEND_VAR                                                 !5
         21        DO_ICALL                                                 
   44    22        PRE_INC                                                  !6
         23    >   IS_SMALLER                                               !6, !3
         24      > JMPNZ                                                    ~18, ->17
   47    25    > > RETURN                                                   null

End of function addextracols

Function getrowcount:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/90XUM
function name:  getRowCount
number of ops:  3
compiled vars:  !0 = $faArrayRecords
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   COUNT                                            ~1      !0
          1      > RETURN                                                   ~1
   51     2*     > RETURN                                                   null

End of function getrowcount

Function getorsetvalue:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 15
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 20
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/90XUM
function name:  getOrSetValue
number of ops:  24
compiled vars:  !0 = $recordID, !1 = $col, !2 = $value, !3 = $isExtra, !4 = $isSet, !5 = $faArrayExtraRecords, !6 = $faArrayRecords
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   53     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
          4        RECV                                             !4      
   55     5      > JMPZ                                                     !3, ->15
   56     6    > > JMPZ                                                     !4, ->11
   57     7    >   FETCH_DIM_W                                      $7      !5, !0
          8        ASSIGN_DIM                                               $7, !1
          9        OP_DATA                                                  !2
         10      > JMP                                                      ->14
   60    11    >   FETCH_DIM_R                                      ~9      !5, !0
         12        FETCH_DIM_R                                      ~10     ~9, !1
         13      > RETURN                                                   ~10
         14    > > JMP                                                      ->23
   64    15    > > JMPZ                                                     !4, ->20
   65    16    >   FETCH_DIM_W                                      $11     !6, !0
         17        ASSIGN_DIM                                               $11, !1
         18        OP_DATA                                                  !2
         19      > JMP                                                      ->23
   68    20    >   FETCH_DIM_R                                      ~13     !6, !0
         21        FETCH_DIM_R                                      ~14     ~13, !1
         22      > RETURN                                                   ~14
   71    23    > > RETURN                                                   null

End of function getorsetvalue

Function parsecsv:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 28
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 28
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 23
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/90XUM
function name:  parseCSV
number of ops:  30
compiled vars:  !0 = $source, !1 = $lines, !2 = $once, !3 = $count, !4 = $line, !5 = $lineArray, !6 = $faArrayRecords, !7 = $fsArrayColNames
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   73     0  E >   RECV                                             !0      
   75     1        INIT_FCALL                                               'explode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 '%0A'
          4        DO_ICALL                                         $8      
          5        ASSIGN                                                   !1, $8
   77     6        ASSIGN                                                   !2, <false>
   79     7        ASSIGN                                                   !3, 0
   81     8      > FE_RESET_R                                       $12     !1, ->28
          9    > > FE_FETCH_R                                               $12, !4, ->28
   83    10    >   INIT_FCALL                                               'explode'
         11        SEND_VAR                                                 !4
         12        SEND_VAL                                                 '%2C'
         13        DO_ICALL                                         $13     
         14        ASSIGN                                                   !5, $13
   85    15        FETCH_CONSTANT                                   ~15     'once'
         16      > JMPZ                                                     ~15, ->23
   86    17    >   INIT_FCALL                                               'array_merge'
         18        FETCH_DIM_R                                      ~16     !6, !3
         19        SEND_VAL                                                 ~16
         20        SEND_VAR                                                 !5
         21        DO_ICALL                                                 
         22      > JMP                                                      ->25
   89    23    >   ASSIGN                                                   !7, !5
   90    24        ASSIGN                                                   !2, <true>
   93    25    >   POST_INC                                         ~20     !3
         26        ASSIGN                                                   !3, ~20
   81    27      > JMP                                                      ->9
         28    >   FE_FREE                                                  $12
   96    29      > RETURN                                                   null

End of function parsecsv

Function parsefromurl:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/90XUM
function name:  parseFromURL
number of ops:  9
compiled vars:  !0 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   98     0  E >   RECV                                             !0      
   99     1        INIT_METHOD_CALL                                         'parseCSV'
          2        INIT_FCALL                                               'getcurl'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $1      
          5        SEND_VAR_NO_REF_EX                                       $1
          6        DO_FCALL                                      0  $2      
          7      > RETURN                                                   $2
  100     8*     > RETURN                                                   null

End of function parsefromurl

End of class CSVParser.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.55 ms | 1415 KiB | 20 Q