Get previous object to end() of array
<p>I got an array and check if <code>end()</code> exists or is empty. If it is empty I would like to get the previous object of the array. I tried using <code>prev()</code> but that didn't seem to work when applied to <code>end()</code>.</p>

<p>any suggestions? the array can vary in lenght and size.</p>

<p>Thanks for your help guys!</p>

<p>Some code:</p>

<pre><code>$pagination = esc_url( get_next_posts_page_link()); // returns url with slashes
$parts = explode('/', $pagination);
//get the last item
$tag = end($parts);
if ($tag == ""){echo prev($tag); } else{echo $tag;}
</code></pre>
