Heim >Backend-Entwicklung >PHP-Tutorial >这样不行么
$_SESSION[]['id']=$row['id'];
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;}}
<?php$row['id']='cs';$_SESSION['id'][]=$row['id'];foreach ($_SESSION[id] as $value){echo $value;}?>