我的程序从文本框中读取信息并将其显示给用户,因此问题出现在该操作的中间部分。当我更新页面时,如何让$myArray
不重新创建自己?
session_start();
if (!isset($myArray)) $myArray = array();
$myArray[] = $_POST['nameAuthor'];
foreach($myArray as $key=>$value)
{
echo "$key->$value";
}
//$_SESSION['arr'] = $myArray;
答案 0 :(得分:1)
试试这个:
session_start();
if(!isset($_SESSION['arr'])) $_SESSION['arr'] = array();
$_SESSION['arr'][] = $_POST['nameAuthor'];
foreach($_SESSION['arr'] as $key => $value)
{
echo "$key->$value";
}