3v4l.org

run code in 300+ PHP versions simultaneously
<?php // mock class Sheet { public function setCellValue($a, $b) { echo "$a : $b\n"; } }; $sheet = new Sheet(); $ids = ["1", "2", "3"]; $fields = ["firstname", "lastname", "phonenumber"]; $data = [ ['a', 'b', 'bla'], ['John', 'Doe', '555-555-5555'] ]; // end mock //$ids = $_POST["id"]; //$values = $_POST["values"]; $sqlIds = implode(",", $ids); $sqlFields = implode(",", $fields); //$sql="SELECT $sqlFields FROM database WHERE id IN ($sqlIds)"; //$result = mysqli_query($connect, $sql); //$data = []; //while ($row = mysqli_fetch_array($result)) { // $data[] = $row; //} // headers $colLetter = "A"; $rowNumber = 1; // A1...Z1 for header foreach ($fields as $fieldname){ $sheet->setCellValue($colLetter.$rowNumber, $fieldname); $colLetter++; } // A2..Z999 for the rest foreach($data as $row) { $rowNumber++; $colLetter = "A"; foreach ($fields as $i => $fieldname) { $sheet->setCellValue($colLetter.$rowNumber, $row[$i]); $colLetter++; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 27
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 27
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 27
2 jumps found. (Code = 77) Position 1 = 29, Position 2 = 46
Branch analysis from position: 29
2 jumps found. (Code = 78) Position 1 = 30, Position 2 = 46
Branch analysis from position: 30
2 jumps found. (Code = 77) Position 1 = 33, Position 2 = 44
Branch analysis from position: 33
2 jumps found. (Code = 78) Position 1 = 34, Position 2 = 44
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 44
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
Branch analysis from position: 27
filename:       /in/vYc55
function name:  (null)
number of ops:  48
compiled vars:  !0 = $sheet, !1 = $ids, !2 = $fields, !3 = $data, !4 = $sqlIds, !5 = $sqlFields, !6 = $colLetter, !7 = $rowNumber, !8 = $fieldname, !9 = $row, !10 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   NEW                                              $11     'Sheet'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $11
    6     3        ASSIGN                                                   !1, <array>
    7     4        ASSIGN                                                   !2, <array>
    9     5        ASSIGN                                                   !3, <array>
   18     6        INIT_FCALL                                               'implode'
          7        SEND_VAL                                                 '%2C'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $17     
         10        ASSIGN                                                   !4, $17
   19    11        INIT_FCALL                                               'implode'
         12        SEND_VAL                                                 '%2C'
         13        SEND_VAR                                                 !2
         14        DO_ICALL                                         $19     
         15        ASSIGN                                                   !5, $19
   29    16        ASSIGN                                                   !6, 'A'
   30    17        ASSIGN                                                   !7, 1
   33    18      > FE_RESET_R                                       $23     !2, ->27
         19    > > FE_FETCH_R                                               $23, !8, ->27
   34    20    >   INIT_METHOD_CALL                                         !0, 'setCellValue'
         21        CONCAT                                           ~24     !6, !7
         22        SEND_VAL_EX                                              ~24
         23        SEND_VAR_EX                                              !8
         24        DO_FCALL                                      0          
   35    25        PRE_INC                                                  !6
   33    26      > JMP                                                      ->19
         27    >   FE_FREE                                                  $23
   39    28      > FE_RESET_R                                       $27     !3, ->46
         29    > > FE_FETCH_R                                               $27, !9, ->46
   40    30    >   PRE_INC                                                  !7
   41    31        ASSIGN                                                   !6, 'A'
   42    32      > FE_RESET_R                                       $30     !2, ->44
         33    > > FE_FETCH_R                                       ~31     $30, !8, ->44
         34    >   ASSIGN                                                   !10, ~31
   43    35        INIT_METHOD_CALL                                         !0, 'setCellValue'
         36        CONCAT                                           ~33     !6, !7
         37        SEND_VAL_EX                                              ~33
         38        CHECK_FUNC_ARG                                           
         39        FETCH_DIM_FUNC_ARG                               $34     !9, !10
         40        SEND_FUNC_ARG                                            $34
         41        DO_FCALL                                      0          
   44    42        PRE_INC                                                  !6
   42    43      > JMP                                                      ->33
         44    >   FE_FREE                                                  $30
   39    45      > JMP                                                      ->29
         46    >   FE_FREE                                                  $27
   46    47      > RETURN                                                   1

Class Sheet:
Function setcellvalue:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vYc55
function name:  setCellValue
number of ops:  8
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        ROPE_INIT                                     4  ~3      !0
          3        ROPE_ADD                                      1  ~3      ~3, '+%3A+'
          4        ROPE_ADD                                      2  ~3      ~3, !1
          5        ROPE_END                                      3  ~2      ~3, '%0A'
          6        ECHO                                                     ~2
          7      > RETURN                                                   null

End of function setcellvalue

End of class Sheet.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
181.82 ms | 1400 KiB | 15 Q