2012-05-24 23 views
0

我有以下的HTML表單

<form id="form2" name="form2" method="post" action="process.php"> 
<table width="271" border="1"> 
<tr> 
    <td width="5"><input name="txtIdone2" type="text" id="txtIdone2" value="Richard" /></td> 
    <td width="250"> 
    <label for="txtIdone"></label> 
    <input name="txtIdone" type="text" id="txtIdone" value="Hopes" /> 
</td> 
</tr> 
<tr> 
    <td><input name="txtIdone3" type="text" id="txtIdone3" value="Testing" /></td> 
    <td><input name="txtIdone4" type="text" id="txtIdone4" value="this" /></td> 
</tr> 
<tr> 
    <td><input name="txtIdone5" type="text" id="txtIdone5" value="it" /></td> 
    <td><input name="txtIdone6" type="text" id="txtIdone6" value="works" /></td> 
</tr> 
<tr> 
    <td colspan="2"><input type="submit" name="btnTest" id="btnTest" value="Submit" /> 
    </td> 
</tr> 
</table> 
</form> 

即提交給process.php具有以下代碼:

$data = array($_POST); 
print_r ($data); 

簡單。但是,我不是返回一個常規數組,而是收到一個多數組。這裏有一個例子:

Array 
(
    [0] => Array 
     (
      [txtIdone2] => Richard 
      [txtIdone] => Hopes 
      [txtIdone3] => Testing 
      [txtIdone4] => this 
      [txtIdone5] => it 
      [txtIdone6] => works 
     ) 

) 

我只想規則陣列返回。我究竟做錯了什麼?

謝謝。

回答

1

$_POSTalready an array

通過做$data = array($_POST);你正在使數組多維。

嘗試做簡單:

print_r($_POST);