Accessing tide time

  • 1
  • Question
  • Updated 7 years ago

I'm having a small problem while pulling tide data. When I use this code to pull the time for low tide I get an accurate answer one day, but a wrong answer the following day:

$low_tide_time = $parsed_json->tide->tideSummary[8]->date->pretty;
echo $low_tide_time;

The reason for this is clear. The array key (in this case [8]) is not consistently assigned to the same tide data type (low tide) every day. So today [8] may be the array key associated with the time for low tide, but tomorrow [8] will be the array key assigned to sunrise, moonrise, etc.

Is there a way to consistently pull the time based on the name of the tide type (low tide) instead of by array key?

Photo of mtuman1843


  • 8 Posts
  • 0 Reply Likes

Posted 7 years ago

  • 1

Be the first to post a reply!