php - How to know when an array pointer has reached the end where's there are no items -
I'm using end ()
to get the last array object, but I do not want it
I want to know that when there are no items and starts with the beginning of the array.
$ current = $ _SESSION ['current_sang']; $ Song_are = explosion (',', $ _SESSION ['song_aray']); $ Nextkey = array_search ($ current, $ song_array) + 1; $ Last_song = end ($ song_array); If ($ next key == calculation ($ song_array)) {$ nextkey == 0; } $ Next = $ song_array [$ nextkey]; If ($ next == $ last_song) {$ sid = $ song_array [0]; } And {$ sid = $ next; ($ Element = current ($ song_array)) {/ code>
For, as long as we do not reach the end of Sir / // print_r ($ element) and see what you have ... // When finished, go to the next element next ($ song_array); } // Reset pointer in the beginning, if you like reset ($ song_array);
Comments
Post a Comment