Search code examples
phparrayspostvar-dump

$_POST contains array with string, bind it to variable


A var_dump of $_POST gives the following result:

array(1) {
    ["postID"]=>
        array(1) {
            [0]=>
            string(2) "76"
        }
}

I want to bind the data from position [0] -> "76" to a variable called $id. What is the correct way to handle this?

Thanks in advance!


Solution

  • You can access this value doing:

    $id = $_POST['postID'][0];