How to use icons for my current contitions with php ?

  • 1
  • Question
  • Updated 8 years ago
Hello everybody
because am very new with wunder weather API i have a question .

Until now i have this script :

$json_string = file_get_contents("");
$parsed_json = json_decode($json_string);
$location = $parsed_json->{'location'}->{'city'};
$icon = $parsed_json->{'current_observation'}->{'icon'};
$temp_c = $parsed_json->{'current_observation'}->{'temp_c'};
echo " Weather now : ${temp_c} C $icon \n";

My question is, how can i show an icon for my current conditions ?
I know that here are the icon sets but i dont know how to use them into my code !

Can you please help me with a small sample of php-code using icons ?

Thanks in advance
Photo of Weatherps


  • 4 Posts
  • 0 Reply Likes

Posted 8 years ago

  • 1
Photo of afelicioni


  • 227 Posts
  • 43 Reply Likes
Looks like a simple question (but I may have misunderstood it) and a very simple answer can be smoething like the following, if using HTML for output

echo " Weather now : ${temp_c} C <img src='$icon.gif' /> \n";

of course, don't care about the style, just try to play with $icon; maybe using printf() could be written better and easier to read

Were you really looking for this?
Photo of Weatherps


  • 4 Posts
  • 0 Reply Likes
oh yeh, thanks so much afelicioni ;)