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

后端 未结 9 641
旧时难觅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:17

    Destructive, but clean:

    while (arr.length) {
      const Title  = arr.shift();
      const Length = arr.shift();
    
      // Do work.
    }
    

提交回复
热议问题