如何将数组存储到PHP中的会话变量

如何将数组存储到PHP中的会话变量

问题描述:

//返回10从问题表的问题。

//Returns 10 question from questions table

$result = mysqli_query($con,"SELECT question FROM questions ORDER BY rand() LIMIT 10' ");
while($row = mysqli_fetch_row($result))
{
$que[]=$row[0];
}  

现在我需要这个一整套 $阙[] 的存储在一个会话变量。 (即10题)

Now I need to store this whole set of $que[] in a session variable. (i.e 10 questions)

像这样

$_SESSION['question'] = $que[]; 

$my_array[] = $_SESSION['question'];

$ my_array [0] 返回的第一个问题, $ my_array [1] 返回第二个问题,而像那。

so that $my_array[0] returns first question, $my_array[1] returns second questions and like that.

(感谢名单提前为帮助)

(Thanx for the help in advance)

分配

$_SESSION['question'] = $que; 

的print_r($ _ SESSION ['问题'] [0]); 会给你的第一个问题。