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>
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
<html> <body onload="showProduct()"> <div id="dropdown"> Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/O0A65:16 Stack trace: #0 /in/O0A65(48): google_spreadsheet_to_array('0AjzADOdg6QnadH...') #1 {main} thrown in /in/O0A65 on line 16
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.37, 5.6.0 - 5.6.23
<html> <body onload="showProduct()"> <div id="dropdown"> Fatal error: Call to undefined function curl_init() in /in/O0A65 on line 16
Process exited with code 255.
Output for 4.4.5 - 4.4.9
<html> <body onload="showProduct()"> <div id="dropdown"> Fatal error: Call to undefined function: curl_init() in /in/O0A65 on line 16
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
<html> <body onload="showProduct()"> <div id="dropdown"> Fatal error: Call to undefined function: curl_init() in /in/O0A65 on line 16
Process exited with code 255.
Output for 4.3.0 - 4.3.1
<html> <body onload="showProduct()"> <div id="dropdown"> Fatal error: Call to undefined function: curl_init() in /in/O0A65 on line 16

preferences:
269.78 ms | 401 KiB | 364 Q