0

I have have a form element like this

input type='text' name='phone[]'
input type='text' name='phone[]'
input type='text' name='phone[]'

How do i retrieve all three name element using PHP. Thank you.

5
  • 1
    Do a print_r($_POST) in the receiving script and you will see. Commented Nov 7, 2010 at 15:45
  • Or a print_r($_GET) if your HTML form uses method="get" Commented Nov 7, 2010 at 15:47
  • @Pekka I need to get everything and put them in different variable, pls look at the code again, need to get something like $phone1,$phone2 etc. Thank Commented Nov 7, 2010 at 15:48
  • @Cyberomin what exactly is your question? Are you familiar with the basics of dealing with a form in PHP? Commented Nov 7, 2010 at 15:49
  • @Pekka from my question above i have input fields like this input type='text' name='phone[]' input type='text' name='phone[]', how do i get the data into seperate variable using php, i cant do foreach($_POST['phone'] as $phone){}, but it's not working. Commented Nov 7, 2010 at 15:51

2 Answers 2

3

when you do

$phones = $_POST['phone'];

you will get an array of "phones"

per your comment above you can have them in different variables by doing:

$phones[0]
$phones[1]
$phones[0]
Sign up to request clarification or add additional context in comments.

1 Comment

go go go choose it as answer! Thanks!
0

Have your HTML form post to your PHP file, then get the values by:

Load the post array into a variable
$phones = $_POST['phone'];

Then pulling each value from the array

$phones[0];
$phones[1];
$phones[2];
...

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.