Home > Backend Development > PHP Tutorial > 这样不行么

这样不行么

WBOY
Release: 2016-06-23 14:22:35
Original
1156 people have browsed it

$_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;}}
Copy after login

<?php$row['id']='cs';$_SESSION['id'][]=$row['id'];foreach ($_SESSION[id] as $value){echo $value;}?>
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template