Browse files

json object decode and data display

  • Loading branch information...
franciscof5 committed May 9, 2018
1 parent fda2ecc commit bfb3b043bd080908ac8caed9afbfbb3c7e6ac36e
Showing with 31 additions and 10 deletions.
  1. +31 −10 index.php
@@ -1,22 +1,43 @@
$city = $_GET['c1-t'];
if(!isset($city) || $city==NULL)
<!DOCTYPE html>
<title>Bravi Weather Simples</title>
<title>Bravi Weather Simple</title>
<h1>City Weather</h1>
<p>Check out any city weather. Write city name below:</p>
<form method="GET" name="c1" action="index.php">
<input type="text" name="c1-t">
<input type="submit" name="c1-s" value="verify">
$url = ',uk&appid=808268433b2e03a5e15354526a3e7712';
$ch = curl_init($url);
#$fp = fopen("pagina_exemplo.txt", "w");
#curl_setopt($ch, CURLOPT_FILE, $fp);
#curl_setopt($ch, CURLOPT_HEADER, 0);
$url = ''.$city.'&appid=808268433b2e03a5e15354526a3e7712';
#$ch = curl_init($url);
$r = file_get_contents($url);
$j = json_decode($r);
echo '<hr />';
echo 'City: '.$city;
echo '<br />';
echo 'Current main weather: '.$j->weather[0]->main;
echo '<br />';
echo 'Description: '.$j->weather[0]->description;
echo '<br />';
echo 'Temperature: '.$j->main->temp." °F";
echo "teste";
<p>Author: Francisco Matelli Matulovic</p>
<p>Released under GNU GPLv3</p>

0 comments on commit bfb3b04

Please sign in to comment.