我在我的網頁一些形式,如:
<form method="get">
Enter Your Firstname :<input type="text" name="t1" />
Enter Your Lastname :<input type="text" name="t2" />
<input type="submit" name="sb" />
</form>
因此用戶將填補這一形式,我想有這樣的形式逗號
分離例如
值John,Smith
James,Baker
所以這裏是我的PHP代碼
if (isset ($_GET['sb']))
{
$t_array = array("t1","t2");
foreach ($t_array as $key)
{
echo implode(',' , $_GET[$key]);
}
}
當我嘗試這樣做,我得到這個錯誤:
Warning: implode() [<a href='function.implode'>function.implode</a>]: Invalid arguments passed in PATH on line 24
我不知道爲什麼我不能用爆在$ _GET或$ _POST
我怎麼能解決這個問題?
PS:我想用數組,在我的網頁破滅,請不要寫其他的方式
'$ _GET ['t1']'不是一個數組,而是一個字符串。我猜你需要的是爆炸。 – Rikesh
$ _GET [$ key]不是數組。這是一個字符串值。你必須將第二個參數作爲數組傳給implode – Hassan
@Hassan,那麼我怎樣才能接收我的表單數據作爲input1,input2? – user3325376