【问题标题】:How to get description in openweathermap object如何在 openweathermap 对象中获取描述
【发布时间】:2017-05-21 21:14:04
【问题描述】:

我从 OpenWeatherMap 获得以下对象。现在我得到了风速和风向。

$weather->wind->speed
$weather->wind->direction

然后它返回

0.71 m/s 62.5018 ENE

但我想获取东-东北风向描述。我尝试了以下方法,但都没有奏效。如何获取风向描述。

$weather->wind->direction->descption
$weather->wind->direction['desctiption']

【问题讨论】:

    标签: php openweathermap


    【解决方案1】:

    在您的两次尝试中,都知道“描述”拼写错误,这就是它不起作用的原因。

    您可以更正拼写并重试,但您应该可以这样做:

    $weather->wind->direction.description
    

    【讨论】:

      【解决方案2】:

      来自this example,我只需要使用getDescription()

      $weather->wind->direction->getDescription();
      

      【讨论】:

        猜你喜欢
        • 2018-09-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-09-08
        • 2011-09-21
        • 1970-01-01
        • 2021-10-11
        相关资源
        最近更新 更多