这样不行么
程序员文章站
2024-02-18 21:31:16
...
$_SESSION[]['id']=$row['id'];
foreach ($_SESSION['id'] as $key=>$value){
echo $value;
}
foreach ($_SESSION['id'] as $key=>$value){
echo $value;
}
回复讨论(解决方案)
$_SESSION[]['id']=$row['id'];
这是不行的!
未指定的项只能出现在最后比如
$_SESSION['id'][] = $row['id'];
改成这样看一下!
$_SESSION['id']=$row['id'];
foreach ($_SESSION as $key=>$value){
echo $value;
}
?>
不是 $_SESSION['id']=$row['id'];这个只能存一个 我存很多个id
然后遍历出来
不是跟你说了吗 $_SESSION['id'][] = $row['id'];
$_SESSION['id'][]=$row['id'];foreach ($_SESSION as $value1){foreach ($value1 as $value2){echo $value2;}}