title: PHP foreach causes "Invalid argument supplied for foreach()"
body: <p>I have a foreach loop that does something depending on the contents of an ACF repeater field (map_destinations). It works fine if there are destinations, but if there aren't I get:</p>
  
  <blockquote>
    <p>"Invalid argument supplied for foreach()"</p>
  </blockquote>
  
  <p>Here's my code:</p>
  
  <pre><code>$map_destinations = get_field('map_destinations', $tour_id);        
  $map = array();
      foreach ($map_destinations as $map_destination) {
      $map[] = $map_destination['destination'];
  }
  </code></pre>
  
  <p>I have tried various solutions but none work. The most commonly accepted method seems to be:</p>
  
  <pre><code>$map_destinations = get_field('map_destinations', $tour_id);        
  $map = array();
  if (is_array($map)) {
      foreach ($map_destinations as $map_destination) {
      $map[] = $map_destination['destination'];
      }
  }
  </code></pre>
  
  <p>Where am I going wrong? Please bear with me, I am just getting to grips with php.</p>