mreish Posted June 22, 2008 Share Posted June 22, 2008 I'm building a "Tell a Friend" type script where the user can add input fields so that when they hit submit, there could be 1 or 100 input fields. I can see each field using this: echo print_r($_POST, true); Which gives the output: Array ( [personalMessage] => message text goes here. [email1] => bill@email.com [email2] => sue@email.com [email3] => [email4] => [email5] => [email6] => [description] => Tell a friend ) But because there are other elements in the $_POST array (such as personalMessage and description) I'm not sure how to parse for the email elements. Any constructive input or tips is most welcome! Quote Link to comment https://forums.phpfreaks.com/topic/111287-solved-formarray-processing-unknown-number-of-_post/ Share on other sites More sharing options...
.josh Posted June 22, 2008 Share Posted June 22, 2008 in your form, change name = 'email1', name = 'email2' etc... to name = 'email[]' for all of them and then foreach($_POST['email'] as $email) { // example echo "$email <br />"; } Quote Link to comment https://forums.phpfreaks.com/topic/111287-solved-formarray-processing-unknown-number-of-_post/#findComment-571236 Share on other sites More sharing options...
mreish Posted June 22, 2008 Author Share Posted June 22, 2008 Aw man, I knew that but I don't do it very often so I completely forgot about it! Thanks a ton! Quote Link to comment https://forums.phpfreaks.com/topic/111287-solved-formarray-processing-unknown-number-of-_post/#findComment-571506 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.