Looping through array and output as pairs (divider for each second element)

后端 未结 9 533
旧时难觅i
旧时难觅i 2021-01-18 03:41

I have an array with anonymous elements. Elements are added to the array via php, like so:

$playlist = array();

while (databaseloop) {
  $playlist[] = $a_ti         


        
9条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-18 04:15

    You could split the array into an array of two-element arrays.

    var arr = ["Hello.mp3", "00:00:14", "Byebye.mp3", "00:00:30", "Whatsup.mp3", "00:00:07", "Goodnight.mp3", "00:00:19"];
    arr.map(function(elem,i,arr){return [elem, (i+1

提交回复
热议问题