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 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
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
Output for 8.0.13 - 8.0.30
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo 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 failed: System error in /in/0LC2u on line 7 <html><body><table> <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
Output for 8.0.0 - 8.0.12
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution 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 failed: Temporary failure in name resolution in /in/0LC2u on line 7 <html><body><table> <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
Output for 7.0.20, 7.1.5 - 7.1.33, 7.2.0 - 7.2.24, 7.3.0 - 7.3.12, 7.3.32 - 7.3.33, 7.4.0, 7.4.26 - 7.4.33
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo 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 failed: System error in /in/0LC2u on line 7 <html><body><table> <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
Output for 7.2.29 - 7.2.33, 7.3.16 - 7.3.31, 7.4.3 - 7.4.25
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution 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 failed: Temporary failure in name resolution in /in/0LC2u on line 7 <html><body><table> <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
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.25, 7.0.0 - 7.0.10, 7.1.0
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known 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 failed: Name or service not known in /in/0LC2u on line 7 <html><body><table> <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

preferences:
252.92 ms | 403 KiB | 269 Q