我填写了这样一个会话:
$_SESSION[$id]=$value;
我正在用这个读出数组:
foreach($_SESSION AS $value){...}
但是我怎样才能读出会话的$id
呢?数组键?
谢谢!
答案 0 :(得分:5)
foreach($_SESSION as $key => $value){
}
答案 1 :(得分:4)
您需要以下内容:
foreach($_SESSION AS $key => $value) {
echo "$key -> $value";
}
答案 2 :(得分:3)
foreach ($_SESSION as $key => $value)
答案 3 :(得分:2)
foreach ($_SESSION as $key => $value) {
print $key . '<br>';
print $value;
}
答案 4 :(得分:2)
foreach ($_SESSION as $key => $value) {
echo $key ;
echo $value;
}
答案 5 :(得分:0)
$array = array();
/*$array = array(0 => "Value");*/
$array[0] = "Value";
$_SESSION["array"] = $array;
/*$_SESSION["array"][0]= "Value 2";*/
foreach($_SESSION["array"] as $key => $value){
print $key;
print $value;
}