2

I have a table that is being written out in PHP, here is one line:

echo ("<td><input name=\"size[$i]\" type=\"text\" id=\"size[$i]\" value=\"$size[$i]\"></td>\r\n");

Let's say for this example $i=4, when I am using $_REQUEST to retrieve the value of $size[4], how do I do that?

I think I could use a FOR EACH to get ALL the values of $size but how do I get only this specific value?

2
  • 1
    replace $size[$i] with $size[4]? Commented Mar 2, 2012 at 15:51
  • i wouldn't recommend using $_REQUEST, but instead, $_GET, $_POST, or $_COOKIE unless you dont mind the data coming from any of those Commented Mar 2, 2012 at 15:53

3 Answers 3

4

Let's say for this example $i=4, when I am using $_REQUEST to retrieve the value of $size[4], how do I do that?

Like this:

echo  $_REQUEST['size']['4'];
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I tried this but with '4' instead of 4. This got what I needed!
1

Why would you use $_REQUEST which is an array containing $_GET, $_POST and $_COOKIE values. You would be much better off requesting the $size[4] with a plain $_GET or $_POST depending on the action of the form.

Comments

0

Have a look here: PHP $_REQUEST as array . I believe they pretty much cover how to get elements from the $_REQUEST-array.

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.