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] => [email protected] [email2] => [email protected] [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! 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 />"; } 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! 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
Archived
This topic is now archived and is closed to further replies.