2010-06-07 107 views
4

所有,获取POST变量是一个数组

我有以下的隐藏变量:

<input type="hidden" name="chk[10]" value = "cats"> 
<input type="hidden" name="chk[13]" value = "dogs"> 
<input type="hidden" name="chk[14]" value = "fish"> 

我想通过POST来获得这些变量并打印。我怎样才能在PHP中做到这一点?

感谢

+0

http://php.net/types.array http://php.net/manual/en/control-structures.foreach.php – 2010-06-07 15:53:25

回答

8
foreach($_POST['chk'] as $key => $value) { 
    echo $key, ' => ', $value, '<br />'; 
} 
2
$chks = $_POST["chk"]; 
print_r($chks);