3v4l.org

run code in 300+ PHP versions simultaneously
<?php $path = dirname(dirname(__FILE__)); define('ROOT',dirname($path)); ?> <?php //error_reporting(E_ERROR); date_default_timezone_set('Etc/GMT+4'); $datetime=date('d/m/Y H:i'); ?> <?php $file = file("http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=ISAINTBA2&day=".date("d",time())."&month=".date("m",time())."&year=".date("Y",time())."&dayend=".date("d",time())."&monthend=".date("m",time())."&yearend=".date("Y",time())."&graphspan=custom&format=1"); unset($file[0]); $file[1]=substr($file[1], 0, -5).",\n"; foreach ($file as $key => $value) { if ($file[$key]=="<br>\n"){ unset($file[$key]); } } $ts = time(); file_put_contents("graphday".$ts.".csv", implode("", $file)); unset($file); $rows = array_map('str_getcsv', file("graphday".$ts.".csv")); $header = array_shift($rows); $ISAINTBA2 = array(); foreach ($rows as $row) { $ISAINTBA2[] = array_combine(array_intersect_key($header, $row), array_intersect_key($row, $header)); } unlink("graphday".$ts.".csv"); ?> <?php $file = file("http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=ISAINTBA22&day=".date("d",time())."&month=".date("m",time())."&year=".date("Y",time())."&dayend=".date("d",time())."&monthend=".date("m",time())."&yearend=".date("Y",time())."&graphspan=custom&format=1"); unset($file[0]); $file[1]=substr($file[1], 0, -5).",\n"; foreach ($file as $key => $value) { if ($file[$key]=="<br>\n"){ unset($file[$key]); } } $ts = time(); file_put_contents("graphday".$ts.".csv", implode("", $file)); unset($file); $rows = array_map('str_getcsv', file("graphday".$ts.".csv")); $header = array_shift($rows); $ISAINTBA22 = array(); foreach ($rows as $row) { $ISAINTBA22[] = array_combine(array_intersect_key($header, $row), array_intersect_key($row, $header)); } unlink("graphday".$ts.".csv"); ?> <?php $file = file("http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=ISAINTBA13&day=".date("d",time())."&month=".date("m",time())."&year=".date("Y",time())."&dayend=".date("d",time())."&monthend=".date("m",time())."&yearend=".date("Y",time())."&graphspan=custom&format=1"); unset($file[0]); $file[1]=substr($file[1], 0, -5).",\n"; foreach ($file as $key => $value) { if ($file[$key]=="<br>\n"){ unset($file[$key]); } } $ts = time(); file_put_contents("graphday".$ts.".csv", implode("", $file)); unset($file); $rows = array_map('str_getcsv', file("graphday".$ts.".csv")); $header = array_shift($rows); $ISAINTBA13 = array(); foreach ($rows as $row) { $ISAINTBA13[] = array_combine(array_intersect_key($header, $row), array_intersect_key($row, $header)); } unlink("graphday".$ts.".csv"); ?> <?php $file = file("http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=ISAINTBA9&day=".date("d",time())."&month=".date("m",time())."&year=".date("Y",time())."&dayend=".date("d",time())."&monthend=".date("m",time())."&yearend=".date("Y",time())."&graphspan=custom&format=1"); unset($file[0]); $file[1]=substr($file[1], 0, -5).",\n"; foreach ($file as $key => $value) { if ($file[$key]=="<br>\n"){ unset($file[$key]); } } $ts = time(); file_put_contents("graphday".$ts.".csv", implode("", $file)); unset($file); $rows = array_map('str_getcsv', file("graphday".$ts.".csv")); $header = array_shift($rows); $ISAINTBA9 = array(); foreach ($rows as $row) { $ISAINTBA9[] = array_combine(array_intersect_key($header, $row), array_intersect_key($row, $header)); } unlink("graphday".$ts.".csv"); ?> <?php $file = file("http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=ISAINTBA20&day=".date("d",time())."&month=".date("m",time())."&year=".date("Y",time())."&dayend=".date("d",time())."&monthend=".date("m",time())."&yearend=".date("Y",time())."&graphspan=custom&format=1"); unset($file[0]); $file[1]=substr($file[1], 0, -5).",\n"; foreach ($file as $key => $value) { if ($file[$key]=="<br>\n"){ unset($file[$key]); } } $ts = time(); file_put_contents("graphday".$ts.".csv", implode("", $file)); unset($file); $rows = array_map('str_getcsv', file("graphday".$ts.".csv")); $header = array_shift($rows); $ISAINTBA20 = array(); foreach ($rows as $row) { $ISAINTBA20[] = array_combine(array_intersect_key($header, $row), array_intersect_key($row, $header)); } unlink("graphday".$ts.".csv"); ?> <?php $file = file("http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=ISAINTBA3&day=".date("d",time())."&month=".date("m",time())."&year=".date("Y",time())."&dayend=".date("d",time())."&monthend=".date("m",time())."&yearend=".date("Y",time())."&graphspan=custom&format=1"); unset($file[0]); $file[1]=substr($file[1], 0, -5).",\n"; foreach ($file as $key => $value) { if ($file[$key]=="<br>\n"){ unset($file[$key]); } } $ts = time(); file_put_contents("graphday".$ts.".csv", implode("", $file)); unset($file); $rows = array_map('str_getcsv', file("graphday".$ts.".csv")); $header = array_shift($rows); $ISAINTBA3 = array(); foreach ($rows as $row) { $ISAINTBA3[] = array_combine(array_intersect_key($header, $row), array_intersect_key($row, $header)); } unlink("graphday".$ts.".csv"); ?> <?php $file = file("http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=ISTBARTH2&day=".date("d",time())."&month=".date("m",time())."&year=".date("Y",time())."&dayend=".date("d",time())."&monthend=".date("m",time())."&yearend=".date("Y",time())."&graphspan=custom&format=1"); unset($file[0]); $file[1]=substr($file[1], 0, -5).",\n"; foreach ($file as $key => $value) { if ($file[$key]=="<br>\n"){ unset($file[$key]); } } $ts = time(); file_put_contents("graphday".$ts.".csv", implode("", $file)); unset($file); $rows = array_map('str_getcsv', file("graphday".$ts.".csv")); $header = array_shift($rows); $ISTBARTH2 = array(); foreach ($rows as $row) { $ISTBARTH2[] = array_combine(array_intersect_key($header, $row), array_intersect_key($row, $header)); } unlink("graphday".$ts.".csv"); ?> <?php $temp_ISAINTBA2 = $ISAINTBA2[count($ISAINTBA2)-1]['TemperatureHighC']; $temp_ISAINTBA22 = $ISAINTBA22[count($ISAINTBA22)-1]['TemperatureHighC']; $temp_ISAINTBA13 = $ISAINTBA13[count($ISAINTBA13)-1]['TemperatureHighC']; $temp_ISAINTBA9 = $ISAINTBA9[count($ISAINTBA9)-1]['TemperatureHighC']; $temp_ISAINTBA20 = $ISAINTBA20[count($ISAINTBA20)-1]['TemperatureHighC']; $temp_ISAINTBA3 = $ISAINTBA3[count($ISAINTBA3)-1]['TemperatureHighC']; $temp_ISTBARTH2 = $ISTBARTH2[count($ISTBARTH2)-1]['TemperatureHighC']; $max_temp = max($temp_ISAINTBA2,$temp_ISAINTBA22,$temp_ISAINTBA13,$temp_ISAINTBA9,$temp_ISAINTBA20,$temp_ISAINTBA3,$temp_ISTBARTH2); $min_temp = min($temp_ISAINTBA2,$temp_ISAINTBA22,$temp_ISAINTBA13,$temp_ISAINTBA9,$temp_ISAINTBA20,$temp_ISAINTBA3,$temp_ISTBARTH2); if ($max_temp==0){ $max_temp=1; } $map_temp_ISAINTBA2 = map_to_float($temp_ISAINTBA2, $min_temp, $max_temp, 0, 180); $map_temp_ISAINTBA22 = map_to_float($temp_ISAINTBA22, $min_temp, $max_temp, 0, 180); $map_temp_ISAINTBA13 = map_to_float($temp_ISAINTBA13, $min_temp, $max_temp, 0, 180); $map_temp_ISAINTBA9 = map_to_float($temp_ISAINTBA9, $min_temp, $max_temp, 0, 180); $map_temp_ISAINTBA20 = map_to_float($temp_ISAINTBA20, $min_temp, $max_temp, 0, 180); $map_temp_ISAINTBA3 = map_to_float($temp_ISAINTBA3, $min_temp, $max_temp, 0, 180); $map_temp_ISTBARTH2 = map_to_float($temp_ISTBARTH2, $min_temp, $max_temp, 0, 180); echo exec('convert -size 831x531 xc: -sparse-color shepards "275,195 gray('.$map_temp_ISAINTBA2.') 220,205 gray('.$map_temp_ISAINTBA22.') 300,225 gray('.$map_temp_ISAINTBA13.') 300,320 gray('.$map_temp_ISAINTBA9.') 405,300 gray('.$map_temp_ISAINTBA20.') 510,240 gray('.$map_temp_ISAINTBA3.') 585,310 gray('.$map_temp_ISTBARTH2.')" -blur 0x30 temp_shape.png'); echo exec('convert -alpha Shape temp_shape.png -normalize -transparent black -channel RGB -auto-level +level-colors OrangeRed pre_temp_out_1.png'); $map_temp_ISAINTBA2 = map_to_float($temp_ISAINTBA2, $min_temp, $max_temp, 180, 0); $map_temp_ISAINTBA22 = map_to_float($temp_ISAINTBA22, $min_temp, $max_temp, 180, 0); $map_temp_ISAINTBA13 = map_to_float($temp_ISAINTBA13, $min_temp, $max_temp, 180, 0); $map_temp_ISAINTBA9 = map_to_float($temp_ISAINTBA9, $min_temp, $max_temp, 180, 0); $map_temp_ISAINTBA20 = map_to_float($temp_ISAINTBA20, $min_temp, $max_temp, 180, 0); $map_temp_ISAINTBA3 = map_to_float($temp_ISAINTBA3, $min_temp, $max_temp, 180, 0); $map_temp_ISTBARTH2 = map_to_float($temp_ISTBARTH2, $min_temp, $max_temp, 180, 0); echo exec('convert -size 831x531 xc: -sparse-color shepards "275,195 gray('.$map_temp_ISAINTBA2.') 220,205 gray('.$map_temp_ISAINTBA22.') 300,225 gray('.$map_temp_ISAINTBA13.') 300,320 gray('.$map_temp_ISAINTBA9.') 405,300 gray('.$map_temp_ISAINTBA20.') 510,240 gray('.$map_temp_ISAINTBA3.') 585,310 gray('.$map_temp_ISTBARTH2.')" -blur 0x30 temp_shape.png'); echo exec('convert -alpha Shape temp_shape.png -normalize -transparent black -channel RGB -auto-level +level-colors blue pre_temp_out_2.png'); echo exec("composite -compose Over pre_temp_out_1.png pre_temp_out_2.png temp_out.png"); echo exec("convert temp_out.png -fill white -annotate +275+195 '".$temp_ISAINTBA2." °C' temp_out_1.png"); echo exec("convert temp_out_1.png -fill white -annotate +220+205 '".$temp_ISAINTBA22." °C' temp_out_2.png"); echo exec("convert temp_out_2.png -fill white -annotate +300+235 '".$temp_ISAINTBA13." °C' temp_out_3.png"); echo exec("convert temp_out_3.png -fill white -annotate +300+320 '".$temp_ISAINTBA9." °C' temp_out_4.png"); echo exec("convert temp_out_4.png -fill white -annotate +405+300 '".$temp_ISAINTBA20." °C' temp_out_5.png"); echo exec("convert temp_out_5.png -fill white -annotate +510+240 '".$temp_ISAINTBA3." °C' temp_out_6.png"); echo exec("convert temp_out_6.png -fill white -annotate +575+290 '".$temp_ISTBARTH2." °C' temp_out_7.png"); echo exec('convert temp_out_7.png -gravity NorthWest -stroke "#000C" -strokewidth 2 -annotate 0 "Meteo-SBH.com - Temperatures Max St Barth" -stroke none -fill white -annotate 0 "Meteo-SBH.com - Temperatures Max St Barth" temp_out_8.png'); echo exec('convert temp_out_8.png -gravity SouthEast -stroke "#000C" -strokewidth 2 -annotate 0 "'.$datetime.'" -stroke none -fill white -annotate 0 "'.$datetime.'" temp_out_9.png'); echo exec("composite -compose Over temp_out_9.png sbh.png temp_max_sbh.png"); echo "<img src='temp_max_sbh.png'>"; ?> <?php $temp_ISAINTBA2 = $ISAINTBA2[count($ISAINTBA2)-1]['TemperatureLowC']; $temp_ISAINTBA22 = $ISAINTBA22[count($ISAINTBA22)-1]['TemperatureLowC']; $temp_ISAINTBA13 = $ISAINTBA13[count($ISAINTBA13)-1]['TemperatureLowC']; $temp_ISAINTBA9 = $ISAINTBA9[count($ISAINTBA9)-1]['TemperatureLowC']; $temp_ISAINTBA20 = $ISAINTBA20[count($ISAINTBA20)-1]['TemperatureLowC']; $temp_ISAINTBA3 = $ISAINTBA3[count($ISAINTBA3)-1]['TemperatureLowC']; $temp_ISTBARTH2 = $ISTBARTH2[count($ISTBARTH2)-1]['TemperatureLowC']; $max_temp = max($temp_ISAINTBA2,$temp_ISAINTBA22,$temp_ISAINTBA13,$temp_ISAINTBA9,$temp_ISAINTBA20,$temp_ISAINTBA3,$temp_ISTBARTH2); $min_temp = min($temp_ISAINTBA2,$temp_ISAINTBA22,$temp_ISAINTBA13,$temp_ISAINTBA9,$temp_ISAINTBA20,$temp_ISAINTBA3,$temp_ISTBARTH2); if ($max_temp==0){ $max_temp=1; } $map_temp_ISAINTBA2 = map_to_float($temp_ISAINTBA2, $min_temp, $max_temp, 0, 180); $map_temp_ISAINTBA22 = map_to_float($temp_ISAINTBA22, $min_temp, $max_temp, 0, 180); $map_temp_ISAINTBA13 = map_to_float($temp_ISAINTBA13, $min_temp, $max_temp, 0, 180); $map_temp_ISAINTBA9 = map_to_float($temp_ISAINTBA9, $min_temp, $max_temp, 0, 180); $map_temp_ISAINTBA20 = map_to_float($temp_ISAINTBA20, $min_temp, $max_temp, 0, 180); $map_temp_ISAINTBA3 = map_to_float($temp_ISAINTBA3, $min_temp, $max_temp, 0, 180); $map_temp_ISTBARTH2 = map_to_float($temp_ISTBARTH2, $min_temp, $max_temp, 0, 180); echo exec('convert -size 831x531 xc: -sparse-color shepards "275,195 gray('.$map_temp_ISAINTBA2.') 220,205 gray('.$map_temp_ISAINTBA22.') 300,225 gray('.$map_temp_ISAINTBA13.') 300,320 gray('.$map_temp_ISAINTBA9.') 405,300 gray('.$map_temp_ISAINTBA20.') 510,240 gray('.$map_temp_ISAINTBA3.') 585,310 gray('.$map_temp_ISTBARTH2.')" -blur 0x30 temp_shape.png'); echo exec('convert -alpha Shape temp_shape.png -normalize -transparent black -channel RGB -auto-level +level-colors OrangeRed pre_temp_out_1.png'); $map_temp_ISAINTBA2 = map_to_float($temp_ISAINTBA2, $min_temp, $max_temp, 180, 0); $map_temp_ISAINTBA22 = map_to_float($temp_ISAINTBA22, $min_temp, $max_temp, 180, 0); $map_temp_ISAINTBA13 = map_to_float($temp_ISAINTBA13, $min_temp, $max_temp, 180, 0); $map_temp_ISAINTBA9 = map_to_float($temp_ISAINTBA9, $min_temp, $max_temp, 180, 0); $map_temp_ISAINTBA20 = map_to_float($temp_ISAINTBA20, $min_temp, $max_temp, 180, 0); $map_temp_ISAINTBA3 = map_to_float($temp_ISAINTBA3, $min_temp, $max_temp, 180, 0); $map_temp_ISTBARTH2 = map_to_float($temp_ISTBARTH2, $min_temp, $max_temp, 180, 0); echo exec('convert -size 831x531 xc: -sparse-color shepards "275,195 gray('.$map_temp_ISAINTBA2.') 220,205 gray('.$map_temp_ISAINTBA22.') 300,225 gray('.$map_temp_ISAINTBA13.') 300,320 gray('.$map_temp_ISAINTBA9.') 405,300 gray('.$map_temp_ISAINTBA20.') 510,240 gray('.$map_temp_ISAINTBA3.') 585,310 gray('.$map_temp_ISTBARTH2.')" -blur 0x30 temp_shape.png'); echo exec('convert -alpha Shape temp_shape.png -normalize -transparent black -channel RGB -auto-level +level-colors blue pre_temp_out_2.png'); echo exec("composite -compose Over pre_temp_out_1.png pre_temp_out_2.png temp_out.png"); echo exec("convert temp_out.png -fill white -annotate +275+195 '".$temp_ISAINTBA2." °C' temp_out_1.png"); echo exec("convert temp_out_1.png -fill white -annotate +220+205 '".$temp_ISAINTBA22." °C' temp_out_2.png"); echo exec("convert temp_out_2.png -fill white -annotate +300+235 '".$temp_ISAINTBA13." °C' temp_out_3.png"); echo exec("convert temp_out_3.png -fill white -annotate +300+320 '".$temp_ISAINTBA9." °C' temp_out_4.png"); echo exec("convert temp_out_4.png -fill white -annotate +405+300 '".$temp_ISAINTBA20." °C' temp_out_5.png"); echo exec("convert temp_out_5.png -fill white -annotate +510+240 '".$temp_ISAINTBA3." °C' temp_out_6.png"); echo exec("convert temp_out_6.png -fill white -annotate +575+290 '".$temp_ISTBARTH2." °C' temp_out_7.png"); echo exec('convert temp_out_7.png -gravity NorthWest -stroke "#000C" -strokewidth 2 -annotate 0 "Meteo-SBH.com - Temperatures Min St Barth" -stroke none -fill white -annotate 0 "Meteo-SBH.com - Temperatures Min St Barth" temp_out_8.png'); echo exec('convert temp_out_8.png -gravity SouthEast -stroke "#000C" -strokewidth 2 -annotate 0 "'.$datetime.'" -stroke none -fill white -annotate 0 "'.$datetime.'" temp_out_9.png'); echo exec("composite -compose Over temp_out_9.png sbh.png temp_min_sbh.png"); echo "<img src='temp_min_sbh.png'>"; ?> <?php function map_to_float($x, $a, $b, $c, $d) { //$f=$x/($b-$a)*($d-$c)+$c; //return $f; return (($x - $a) * ($d - $c) / ($b - $a) + $c); } ?>

preferences:
39.51 ms | 402 KiB | 5 Q