将多个值存储在由逗号分隔的同一列中

时间:2019-07-29 17:31:52

标签: php mysql

字符串:23456,16524,84755,98457,06978,05986,73454,34785

结果

23456

16524

84755

98457

06978

05986

73454

34785

1 个答案:

答案 0 :(得分:0)

只需explode()即可通过逗号分隔符来分解字符串。

var numberOfCubes = 8;
var rotationsSet = [
    'rotateX(90deg)',
    'rotateX(-90deg)',
    'rotateY(90deg)',
    'rotateY(-90deg)',
    'rotateX(180deg)'
    ];

var shuffledRotationsSets = Array(numberOfCubes).fill(['']);

// Fisher-Yates array shuffle
function shuffle(array) {
    for (let i = array.length - 1; i > 0; i--) {
        let j = Math.floor(Math.random() * (i + 1)); 
        [array[i], array[j]] = [array[j], array[i]]; 
    }
}

function initShuffledSets() {
    for (let z = 0; z < shuffledRotationsSets.length; z++) { 
        shuffledRotationsSets[z] = rotationsSet;
        shuffle(shuffledRotationsSets[z]);
    }
}

initShuffledSets();

工作demo