4

我填写这样的会话:

$_SESSION[$id]=$value;

我正在用这个读出数组:

foreach($_SESSION AS $value){...}

但是我怎样才能读出$id会话的内容呢?数组键?

谢谢!

4

6 回答 6

6
foreach($_SESSION as $key => $value){
}

http://br2.php.net/manual/en/control-structures.foreach.php

于 2013-09-12T12:21:49.390 回答
4

您需要以下内容:

foreach($_SESSION AS $key => $value) {
  echo "$key -> $value";
}
于 2013-09-12T12:20:51.243 回答
3
foreach ($_SESSION as $key => $value)
于 2013-09-12T12:20:39.167 回答
2
foreach ($_SESSION as $key => $value) {
  echo $key ;
  echo $value;
}
于 2013-09-12T12:24:13.780 回答
2
foreach ($_SESSION as $key => $value) {
  print $key . '<br>';
  print $value;
}
于 2013-09-12T12:20:56.880 回答
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;
}
于 2016-10-06T13:06:35.853 回答