3v4l.org

run code in 300+ PHP versions simultaneously
<html> <body onload="showProduct()"> <div id="dropdown"> <?php /** * Download & parse Google spreadsheet content * * @param unknown_type $link */ function google_spreadsheet_to_array($key) { // initialize URL $url = 'http://spreadsheets.google.com/feeds/cells/' . $key . '/1/public/values'; // initialize curl $curl = curl_init(); // set curl options curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); // get the spreadsheet using curl $google_sheet = curl_exec($curl); // close the curl connection curl_close($curl); // import the xml file into a SimpleXML object $feed = new SimpleXMLElement($google_sheet); // get every entry (cell) from the xml object // extract the column and row from the cell's title // e.g. A1 becomes [1][A] $array = array(); foreach ($feed->entry as $entry) { $location = (string) $entry->title; preg_match('/(?P<column>[A-Z]+)(?P<row>[0-9]+)/', $location, $matches); $array[$matches['row']][$matches['column']] = (string) $entry->content; } // return the array return $array; } $SP_KEY = "0AjzADOdg6QnadHZTVDI5MU83NVE4MFpxMmFHOXR2S1E"; $data = google_spreadsheet_to_array($SP_KEY); echo' <select name="Product" id="Product" onchange="showProduct()">'; foreach($data[1] as $products){ echo'<option value="'.$products.'">'.$products.'</option>'; } echo'</select>\n\n'; echo' <select name="Category" id="Category" onchange="showProduct()">'; foreach($data as $categories){ if($categories[A] != "Product" and $categories[A] != "") echo'<option value="'.$categories[A].'">'.$categories[A].'</option>'; } ?> <div id="demo"> </div> <script> function showProduct() { var product = document.getElementById('Product').value; document.getElementById("demo").innerHTML="bloop "+product+"!"; } </script> </div> </body> </html>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 16
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 16
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 40
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 40
Branch analysis from position: 21
2 jumps found. (Code = 46) Position 1 = 25, Position 2 = 29
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 39
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 39
Branch analysis from position: 29
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
Branch analysis from position: 16
filename:       /in/O0A65
function name:  (null)
number of ops:  43
compiled vars:  !0 = $SP_KEY, !1 = $data, !2 = $products, !3 = $categories
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    1     0  E >   ECHO                                                     '%3Chtml%3E%0A%3Cbody+onload%3D%22showProduct%28%29%22%3E%0A%3Cdiv+id%3D%22dropdown%22%3E%0A'
   47     1        ASSIGN                                                   !0, '0AjzADOdg6QnadHZTVDI5MU83NVE4MFpxMmFHOXR2S1E'
   48     2        INIT_FCALL                                               'google_spreadsheet_to_array'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $5      
          5        ASSIGN                                                   !1, $5
   49     6        ECHO                                                     '+%3Cselect+name%3D%22Product%22+id%3D%22Product%22+onchange%3D%22showProduct%28%29%22%3E'
   50     7        FETCH_DIM_R                                      ~7      !1, 1
          8      > FE_RESET_R                                       $8      ~7, ->16
          9    > > FE_FETCH_R                                               $8, !2, ->16
   51    10    >   CONCAT                                           ~9      '%3Coption+value%3D%22', !2
         11        CONCAT                                           ~10     ~9, '%22%3E'
         12        CONCAT                                           ~11     ~10, !2
         13        CONCAT                                           ~12     ~11, '%3C%2Foption%3E'
         14        ECHO                                                     ~12
   50    15      > JMP                                                      ->9
         16    >   FE_FREE                                                  $8
   54    17        ECHO                                                     '%3C%2Fselect%3E%5Cn%5Cn'
   55    18        ECHO                                                     '+%3Cselect+name%3D%22Category%22+id%3D%22Category%22+onchange%3D%22showProduct%28%29%22%3E'
   56    19      > FE_RESET_R                                       $13     !1, ->40
         20    > > FE_FETCH_R                                               $13, !3, ->40
   57    21    >   FETCH_CONSTANT                                   ~14     'A'
         22        FETCH_DIM_R                                      ~15     !3, ~14
         23        IS_NOT_EQUAL                                     ~16     ~15, 'Product'
         24      > JMPZ_EX                                          ~16     ~16, ->29
         25    >   FETCH_CONSTANT                                   ~17     'A'
         26        FETCH_DIM_R                                      ~18     !3, ~17
         27        IS_NOT_EQUAL                                     ~19     ~18, ''
         28        BOOL                                             ~16     ~19
         29    > > JMPZ                                                     ~16, ->39
   58    30    >   FETCH_CONSTANT                                   ~20     'A'
         31        FETCH_DIM_R                                      ~21     !3, ~20
         32        CONCAT                                           ~22     '%3Coption+value%3D%22', ~21
         33        CONCAT                                           ~23     ~22, '%22%3E'
         34        FETCH_CONSTANT                                   ~24     'A'
         35        FETCH_DIM_R                                      ~25     !3, ~24
         36        CONCAT                                           ~26     ~23, ~25
         37        CONCAT                                           ~27     ~26, '%3C%2Foption%3E'
         38        ECHO                                                     ~27
   56    39    > > JMP                                                      ->20
         40    >   FE_FREE                                                  $13
   61    41        ECHO                                                     '%3Cdiv+id%3D%22demo%22%3E+%3C%2Fdiv%3E%0A%3Cscript%3E+%0Afunction+showProduct%28%29+%7B%0A++++var+product+%3D+document.getElementById%28%27Product%27%29.value%3B+%0A++++document.getElementById%28%22demo%22%29.innerHTML%3D%22bloop+%22%2Bproduct%2B%22%21%22%3B%0A%7D%0A%3C%2Fscript%3E%0A%3C%2Fdiv%3E++%0A%3C%2Fbody%3E%0A%3C%2Fhtml%3E'
   70    42      > RETURN                                                   1

Function google_spreadsheet_to_array:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 39, Position 2 = 56
Branch analysis from position: 39
2 jumps found. (Code = 78) Position 1 = 40, Position 2 = 56
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
Branch analysis from position: 56
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 56
filename:       /in/O0A65
function name:  google_spreadsheet_to_array
number of ops:  59
compiled vars:  !0 = $key, !1 = $url, !2 = $curl, !3 = $google_sheet, !4 = $feed, !5 = $array, !6 = $entry, !7 = $location, !8 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   13     1        CONCAT                                           ~9      'http%3A%2F%2Fspreadsheets.google.com%2Ffeeds%2Fcells%2F', !0
          2        CONCAT                                           ~10     ~9, '%2F1%2Fpublic%2Fvalues'
          3        ASSIGN                                                   !1, ~10
   16     4        INIT_FCALL_BY_NAME                                       'curl_init'
          5        DO_FCALL                                      0  $12     
          6        ASSIGN                                                   !2, $12
   19     7        INIT_FCALL_BY_NAME                                       'curl_setopt'
          8        SEND_VAR_EX                                              !2
          9        FETCH_CONSTANT                                   ~14     'CURLOPT_URL'
         10        SEND_VAL_EX                                              ~14
         11        SEND_VAR_EX                                              !1
         12        DO_FCALL                                      0          
   20    13        INIT_FCALL_BY_NAME                                       'curl_setopt'
         14        SEND_VAR_EX                                              !2
         15        FETCH_CONSTANT                                   ~16     'CURLOPT_HEADER'
         16        SEND_VAL_EX                                              ~16
         17        SEND_VAL_EX                                              0
         18        DO_FCALL                                      0          
   21    19        INIT_FCALL_BY_NAME                                       'curl_setopt'
         20        SEND_VAR_EX                                              !2
         21        FETCH_CONSTANT                                   ~18     'CURLOPT_RETURNTRANSFER'
         22        SEND_VAL_EX                                              ~18
         23        SEND_VAL_EX                                              <true>
         24        DO_FCALL                                      0          
   24    25        INIT_FCALL_BY_NAME                                       'curl_exec'
         26        SEND_VAR_EX                                              !2
         27        DO_FCALL                                      0  $20     
         28        ASSIGN                                                   !3, $20
   27    29        INIT_FCALL_BY_NAME                                       'curl_close'
         30        SEND_VAR_EX                                              !2
         31        DO_FCALL                                      0          
   30    32        NEW                                              $23     'SimpleXMLElement'
         33        SEND_VAR_EX                                              !3
         34        DO_FCALL                                      0          
         35        ASSIGN                                                   !4, $23
   36    36        ASSIGN                                                   !5, <array>
   37    37        FETCH_OBJ_R                                      ~27     !4, 'entry'
         38      > FE_RESET_R                                       $28     ~27, ->56
         39    > > FE_FETCH_R                                               $28, !6, ->56
   38    40    >   FETCH_OBJ_R                                      ~29     !6, 'title'
         41        CAST                                          6  ~30     ~29
         42        ASSIGN                                                   !7, ~30
   39    43        INIT_FCALL                                               'preg_match'
         44        SEND_VAL                                                 '%2F%28%3FP%3Ccolumn%3E%5BA-Z%5D%2B%29%28%3FP%3Crow%3E%5B0-9%5D%2B%29%2F'
         45        SEND_VAR                                                 !7
         46        SEND_REF                                                 !8
         47        DO_ICALL                                                 
   40    48        FETCH_DIM_R                                      ~33     !8, 'row'
         49        FETCH_DIM_R                                      ~35     !8, 'column'
         50        FETCH_OBJ_R                                      ~37     !6, 'content'
         51        CAST                                          6  ~38     ~37
         52        FETCH_DIM_W                                      $34     !5, ~33
         53        ASSIGN_DIM                                               $34, ~35
         54        OP_DATA                                                  ~38
   37    55      > JMP                                                      ->39
         56    >   FE_FREE                                                  $28
   44    57      > RETURN                                                   !5
   45    58*     > RETURN                                                   null

End of function google_spreadsheet_to_array

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.78 ms | 1407 KiB | 16 Q