Jake
Jake

Reputation: 26117

Get POST variable that is an array

All,

I have the following hidden variables:

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

I want to get these variables through POST and print them. How can I do this in PHP?

Thanks

Upvotes: 5

Views: 14152

Answers (2)

Imre L
Imre L

Reputation: 6249

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

Upvotes: 10

a1ex07
a1ex07

Reputation: 37364

$chks = $_POST["chk"];
print_r($chks);

Upvotes: 2

Related Questions