title: PHP Warning: count(): Parameter must be an array or an object that implements Countable?
body: <p>On my website I allow people to upload image galleries. When they click an image there is a <strong>next</strong> and <strong>previous</strong> button at the bottom so they can easily scroll back and forth through the images. </p>
  
  <p>I am getting the below error in my log located at /opt/cpanel/ea-php72/root/usr/var/log/php-fpm/</p>
  
  <pre><code>NOTICE: PHP message: PHP Warning:  count(): Parameter must be an array or an object that implements Countable in . . . on line 12
  </code></pre>
  
  <p>It is talking about the line below in my code:</p>
  
  <pre><code>$max = count($photos);
  </code></pre>
  
  <p>Below is the other code that comes with that line:</p>
  
  <pre><code>$photos = get_field('gallery');
  $max = count($photos);    &lt;------- error line here --------&gt;
  $current = (isset($_GET['image'])) ? intval($_GET['image']) : false;
  if ($current !== false) {
      if ($current &gt; $max) $current = $max;
      if ($current &lt; 1) $current = 1;
  }
  
  $next = (($current + 1) &lt; $max) ? ($current + 1) : $max;
  $prev = (($current - 1) &gt; 1) ? ($current - 1) : 1;
  ?&gt;
  </code></pre>
  
  <p>Basically this code uses <strong>get_field('gallery')</strong> to get the total amount of photos in the gallery and the number is assigned to variable <strong>max</strong>.</p>
  
  <p>The rest of the code is how the <strong>next</strong> and <strong>previous</strong> buttons work.</p>
  
  <p>I do not know what is wrong. Can somebody help with this?</p>