0

Im currently trying to build a validation class in PHP. What im trying to do is match the array of validations required with the $_POST array. My validation array gives the following values which are field names

$validation[0] = “order[0][company]”
$validation[1] = “order[1][company]”
$validation[2] = “order[2][company]”

And so on. The $_POST array looks like this

Array ( [order] => Array ( [0] => Array ( [company] => [link] => [username] => [password] => [comments] => ) [1] => Array ( [company] => [link] => [username] => [password] => [comments] => )

How do I access the value from the post array using the field names given above? I tried $_POST[$validation[0]] but it doesn’t seem to work.

0

1 Answer 1

2

$_POST[$validation[0]], with a pair of brackets instead of parentheses, as you'd access any other array.

Sign up to request clarification or add additional context in comments.

1 Comment

Sorry that was a typo in my question, thats what i'm doing.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.