kangbroke — 2011-10-17T20:19:04-04:00 — #1
Is it possible to pull the current weather temperature and add 1 degree to it?
Just trying to full around with Curl for the first time and can not find much documentation on how to do something like this.
immerse — 2011-10-18T02:18:49-04:00 — #2
Well, you will need to find a weather provider to do that. Something like... http://www.google.com/ig/api?weather=The+Hague
Now, you could retrieve that information with cURL, then parse the XML to find current_conditions/temp_c, and then add 1 to that.
kangbroke — 2011-10-18T02:30:10-04:00 — #3
Well now I have that part figured out but before I post the code I have gathered.
In example cURL returns $e=x.xxx
When I use echo $e;
it comes back as x.xxx
when I use echo $e+1;
it comes back as 1
cups — 2011-10-18T03:28:48-04:00 — #4
Find out exactly what curl is bringing back, and what type PHP interprets it to be before simply adding a 1 to it.
kangbroke — 2011-10-18T04:11:19-04:00 — #5
runs on forever.
And when it returns the value $e. I can not get any math out of it.
right now $e echos 2.8. But that changes every so often. But when i try to add
$e + 1 = $f
$html = file_get_html('https://btc-e.com/exchange/');
foreach($html->find('span#min_price') as $e)
echo $e->innertext . '<br>';
cups — 2011-10-18T04:35:28-04:00 — #6
So, can you tell me whether you are getting 2.8 as a string or a float?
That's why I asked you to var_dump() the variable ...
kangbroke — 2011-10-18T04:54:58-04:00 — #7
I copied the entire code above^.
It pulls the current rate off btc-e for bitcoins in usd.
the 2.8 changes.
I have the cURL pulling the correct info, Just not sure how to alter it. I want to be able to take the current rate $e.
and increase it by a percent.
kangbroke — 2011-10-18T05:30:44-04:00 — #8
When I do the var_dump() it never ends....
Almost 100% certain its a string. I did include my code above
cups — 2011-10-18T06:02:09-04:00 — #9
Maybe its the way you are adding the values up? This all works for me:
$fl = (float) 2.8;
$st = "2.8";
// float 2.8
// float 3.8
// string '2.8' (length=3)
// float 3.8
kangbroke — 2011-10-18T06:12:18-04:00 — #10
I will try this, Since you seem to know your way around mind taking a look at the link and telling me how to pull out the information I need