PHP - shuffle only part of an array -
PHP - shuffle only part of an array -
i have array so:
$animals = array ( 'giraffe', 'lion', 'hippo', 'dog', 'cat', 'rabbit', 'fly', 'hamster', 'gerbil' 'goldfish' ); that order want array in apart these 2 - hamster , gerbil
i randomise between 1 comes first. know can use:
shuffle($animals); to randomise them want these 2. if print_r($animals) may hamster come before gerbil time gerbil before hamster
you can splice array elements, randomize order , set them in original array:
php arrays shuffle
Comments
Post a Comment