I'm now using `end()` to get the last array item, but I don't want this. 

I want to know when there are no items and start from the beginning of the array. 

```
$current = $_SESSION['current_song'];
$song_array = explode(',', $_SESSION['song_array']);
$nextkey = array_search($current, $song_array) + 1;
$last_song = end($song_array);

if ($nextkey == count($song_array)){ 
    $nextkey == 0;
}

$next = $song_array[$nextkey];
if ($next == $last_song){
    $sid = $song_array[0];
} else {
    $sid = $next;
}

```