试试这个
<?php
session_start();
// create an array
$my_array=array('cat', 'dog', 'mouse', 'bird', 'crocodile', 'wombat', 'koala', 'kangaroo');
// put the array in a session variable
$_SESSION['animals']=$my_array;
// a little message to say we have done it
echo 'Putting array into a session variable';
// loop through the session array with foreach
foreach($_SESSION['animals'] as $key=>$value)
{
// and print out the values
echo 'The value of $_SESSION['."'".$key."'".'] is '."'".$value."'".' <br />';
}
?>
您的示例我为您使用过的变量赋予了一些价值
<?php
session_start();
$member = 'new';
$allFollowing = 'follower';
$getPoetry['poet'] = $_SESSION[$member]['filters']['newspaper'] = array('$in' => $allFollowing);
print_r($_SESSION[$member]['filters']['newspaper']);
print_r($getPoetry);
?>
@Yogesh Suthar 情况下,他错过了密钥,并且 0 也不应该出现在会话中的第一个密钥检查中
<?php
session_start();
$abcd = $_SESSION['test']['filters']['newspaper'] = array('test'=>"abcd");
print_r($_SESSION['test']['filters']['newspaper']);
print_r($abcd);
?>