Edit report at https://bugs.php.net/bug.php?id=64864&edit=1
ID: 64864 User updated by: mail at kinesis dot me Reported by: mail at kinesis dot me Summary: shuffle() and array_push are broken with PDO. -Status: Open +Status: Closed Type: Bug Package: PDO related Operating System: Ubuntu Linux 13.04 x64 PHP Version: 5.4.15 Block user comment: N Private report: N New Comment: I was seeding the random number generator with 0. Previous Comments: ------------------------------------------------------------------------ [2013-05-16 20:32:52] mail at kinesis dot me Description: ------------ $this->answer['id'] is always at the end, when it is supposed to be shuffled. This looks like a bug to me. array_rand() will not work either. $this->current_set=$this->dbh->query("SELECT DISTINCT id FROM $game_type WHERE id != '".(string)$this->answer['id']."' ORDER BY rand() LIMIT 2;")->fetchAll(PDO::FETCH_COLUMN); //$this->complete_set="" //echo "Current set separated by commas is ".implode(",",$this->current_set->fetchAll(PDO::FETCH_COLUMN)) + $this->answer['id']."<br />"; //$this->current_set=$this->current_set->fetchAll(PDO::FETCH_COLUMN); array_push($this->current_set,$this->answer['id']); explode(",",$this->current_set); shuffle($this->current_set); // $this->answer['id'] is always at the end? print_r($this->current_set); print_r($this->answer['id']); var_dump($this->current_set, 3); Test script: --------------- $this->current_set=$this->dbh->query("SELECT DISTINCT id FROM $game_type WHERE id != '".(string)$this->answer['id']."' ORDER BY rand() LIMIT 2;")->fetchAll(PDO::FETCH_COLUMN); //$this->complete_set="" //echo "Current set separated by commas is ".implode(",",$this->current_set->fetchAll(PDO::FETCH_COLUMN)) + $this->answer['id']."<br />"; //$this->current_set=$this->current_set->fetchAll(PDO::FETCH_COLUMN); array_push($this->current_set,$this->answer['id']); explode(",",$this->current_set); shuffle($this->current_set); // $this->answer['id'] is always at the end? print_r($this->current_set); print_r($this->answer['id']); var_dump($this->current_set, 3); Expected result: ---------------- I expect the array '$this->current_set' to have the value of $this->answer pushed towards the end. Then I shuffle() or array_rand() the array, but $this->answer always appears as the third element of the array no matter what I do. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=64864&edit=1