0

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!

Imanuel
  • 3,596
  • 4
  • 24
  • 46
Moya
  • 89
  • 1
  • 2
  • 10

1 Answers1

1

You can access this value doing:

$id = $_POST['postID'][0];
Agu Dondo
  • 12,638
  • 7
  • 57
  • 68
  • Thanks! I have a follow up question, If you don't mind. Is there a way to trim the data stored in the variable so that it only reads 76 instead of string(2) "76"? – Moya May 06 '17 at 19:23
  • 1
    You see `string(2) "76"` because you are doing var_dump, var_dump is explaining you the value is a string of 2 characters which is "76". The actual value is just "76", you can test it doing `echo $_POST['postID'][0];` – Agu Dondo May 06 '17 at 19:25
  • Thanks for the clarification Agu Dondo! – Moya May 06 '17 at 19:27