|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2013-05-16 22:56 UTC] mail at kinesis dot me
 
-Status: Open
+Status: Closed
  [2013-05-16 22:56 UTC] mail at kinesis dot me
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 12:00:01 2025 UTC | 
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.