3v4l.org

run code in 300+ PHP versions simultaneously
<?php header("Content-type: text/plain"); //period=68 for month, period=67 for weekly, period=56 for daily, only for html $stock="2888"; $arrCSV = array(); $url = "http://chartdata1.internet.aastocks.com/servlet/iDataServlet/getdaily?id=".$stock.".HK&type=24&market=1&level=1&period=56&encoding=big5"; $html = file_get_contents($url); $c = str_replace("|","\r\n",$html); $d = str_replace(";",",",$c); $pos = substr_count($d,'!'); if ($pos == 1){ $file = strstr($d,'!',true); }else{ $file = str_replace("!","\r\n",$d); } { $key = 1; $row = str_getcsv($file, "\n"); $length = count($row); for($i=2;$i<$length;$i++) { $data = str_getcsv($row[$i], ","); //echo '<br/>======<br/>'; //print_r($data); $c = count($data); //print $c . "<BR>"; // <------ 7 o numero de colunas //Populate the array If ($key != 0) { $arrCSV[$key-1][0] = strtotime($data[0]); //Time $arrCSV[$key-1][1] = $data[1]; //Open $arrCSV[$key-1][2] = $data[2]; //High $arrCSV[$key-1][3] = $data[3]; //Low $arrCSV[$key-1][4] = $data[4]; //Adj Close $arrCSV[$key-1][5] = $data[5]*1000; //Volume $arrCSV[$key-1][6] = $data[6]; //Volume1 } $key++; } // end while $keymax = $key; // Close the CSV file } // end if $key = 1; rsort ($arrCSV); foreach($arrCSV as $index => $data) { //echo '<br/>======<br/>'; //print_r($data); $c = count($data); //print $c . "<BR>"; // <------ 6 numero de colunas If ($key != 0) { $arrCSV[$key-1][0] = date('d-m-Y',$data[0]); //Time $arrCSV[$key-1][1] = floatval($data[1]); //Open $arrCSV[$key-1][2] = floatval($data[2]); //High $arrCSV[$key-1][3] = floatval($data[3]); //Low $arrCSV[$key-1][4] = floatval($data[4]); //Close $arrCSV[$key-1][5] = floatval($data[5]); //Volume $arrCSV[$key-1][6] = floatval($data[6]); //Volume1 } //echo '<Br/>'; //print_r($arrCSV[$key-1]); $key++; } // end while $keymax = $key; $a = json_encode($arrCSV,JSON_NUMERIC_CHECK); $b = str_replace('],["',"\r\n",$a); $c = str_replace('",',',',$b); $file = trim($c,'[["]]'); echo "<html><body><table>\n\n"; $row = str_getcsv($file, "\n"); $length = count($row); for($i=0;$i<$length;$i++) { $line = str_getcsv($row[$i], ","); foreach ($line as $cell) { echo "<td>" . htmlspecialchars($cell) . "</td>"; } echo "</tr>\n"; } echo "\n</table></body></html>"; header("Content-type: application/html"); header("Content-disposition: attachment; filename=".$stock."_AA.html"); ?>
Output for git.master, git.master_jit, rfc.property-hooks
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo for chartdata1.internet.aastocks.com failed: System error in /in/0LC2u on line 7 Warning: file_get_contents(http://chartdata1.internet.aastocks.com/servlet/iDataServlet/getdaily?id=2888.HK&type=24&market=1&level=1&period=56&encoding=big5): Failed to open stream: php_network_getaddresses: getaddrinfo for chartdata1.internet.aastocks.com failed: System error in /in/0LC2u on line 7 <html><body><table> Deprecated: str_getcsv(): Passing null to parameter #1 ($string) of type string is deprecated in /in/0LC2u on line 88 Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /in/0LC2u on line 91 <td></td></tr> </table></body></html> Warning: Cannot modify header information - headers already sent by (output started at /in/0LC2u:7) in /in/0LC2u on line 96 Warning: Cannot modify header information - headers already sent by (output started at /in/0LC2u:7) in /in/0LC2u on line 97

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
69.66 ms | 403 KiB | 8 Q