php - Assigning property of StdClass to a variable -


a bit of php noob - have php code downloaded calculates moon rise , set times , returns:

 object(stdclass)#1 (2) { ["moonrise"]=> int(1309219860) ["moonset"]=> int(1309281240) } int(1309219860) 

with messing around managed moonrise assigned variable can use - problem got int in it. how convert integer can use later?

$times = (moon::calculatemoontimes(6, 28, 2011, 43.654406, -3.320222)); $rise = $times->moonrise; echo var_dump($rise); 

this returned:

int(1309219860) 

from php manual documentation var_dump():

this function displays structured information 1 or more expressions includes type , value. arrays , objects explored recursively values indented show structure.

for displaying value, can use echo instead of var_dump():

$times = (moon::calculatemoontimes(6, 28, 2011, 43.654406, -3.320222)); $rise = $times->moonrise; echo $rise; 

also, if want ignore decimal values , return integer, can use intval()

$rise = intval($times->moonrise); echo $rise; 

hope helps!


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -