I have an array with anonymous elements. Elements are added to the array via php, for example:
$playlist = array(); while (databaseloop) { $playlist[] = $a_title; $playlist[] = $a_length; } echo json_encode(array('playlist'=>$playlist));
So the array becomes:
["Hello.mp3", "00:00:14", "Byebye.mp3", "00:00:30", "Whatsup.mp3", "00:00:07", "Goodnight.mp3", "00:00:19"] and so on
Then I get this array in jquery with ajax message. All of this works great.
Now I'm looking for a way to process / output all elements of an array as pairs in javascript / jquery. "do something" for every second element. Like this:
foreach (two_elements_in_array) {
How can I do that?
source share