0

I'm posting an array from a html form with the following input-tag:

<input type="text" name="new_service[1]['category']">

I get this array:

Array
(
    [1] => Array
        (
            ['category'] => 1
            ['description'] => asdasd
            ['price'] => asdasd
            ['time'] => 1
        )

)

When I try to get the category value with

echo $_POST['new_service'][1]['category']; 

I get this error message:

Notice: Undefined index: category

What am I doing wrong?

2 Answers 2

3

The index you create this way is not category but 'category' i.e. you create an index that also has single quotes.

So to echo what you want you should use:

echo $_POST['new_service'][1]["'category'"];

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

Comments

0

Just use $_POST['new_service']; then loop

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.