wobsoriano
wobsoriano

Reputation: 13434

Get value of Post in Array Wordpress

I'm trying to get Post values of an array textbox name in Wordpress. The code is:

<input checked="checked" id="simple_fields_fieldgroups_9_1_0" type="checkbox" name="simple_fields_fieldgroups[9][1][0]" value="1">

How can I get the value of simple_fields_fieldgroups[9][1][0] using POST? When I try $_POST['simple_fields_fieldgroups[9][1][0]'] it will simply not work..

UPDATE:

When I do

print_r($_POST['post_category']);

I get

Array ( [0] => 0 [1] => 18 [2] => 1 )

How can I get the value 18?

Upvotes: 2

Views: 296

Answers (2)

Alex Rindone
Alex Rindone

Reputation: 298

What happens if you use a for each to iterate through the array?

    foreach ($_POST['post_category'] as $key => $value) {
              var_dump($value);
    }
    die();

Otherwise the you can get the value by using:

$_POST['post_category'][1]

That's because since $_POST['post_category'] is an array, you can dump out the value using the value's key within the array.

Upvotes: 1

Alexan Kulbashian
Alexan Kulbashian

Reputation: 21

If it's posting properly, it should be accessible as:

<?php
    $x = $_POST['simple_fields_fieldgroups'][9][1][0];
?>

Upvotes: 1

Related Questions