Check if selected value is last in the array
<p>I have function like this:</p>

<pre><code>function ypg_delete_img($id, $img)
        {
            $q = $this-&gt;ypg_get_one($id);

            $imgs = explode(',', $q-&gt;image);

            if(count($imgs) &gt; 1) :
                $z = ",";
            else :
                $z = "";
                $data['image'] = 'avatar_mali_oglas.png';
                $this-&gt;db-&gt;where('id_yellow_pages', $id);
                $this-&gt;db-&gt;update('yellow_pages', $data);
            endif;
            if($imgs[0] != 'avatar_mali_oglas.png') :
                $query  = "UPDATE `yellow_pages` ";
                $query .= "SET `image` = REPLACE(`image`,'". $img . $z ."', '')
                           WHERE `id_yellow_pages` = $id "; 
                $this-&gt;global_functions-&gt;delete_img('zute_strane', $img);
            $this-&gt;db-&gt;query($query);
            endif; 
        }
</code></pre>

<p>I need to check if <strong>$img</strong> is the last value in the array of <strong>$imgs</strong>. How can I do this?</p>
