I have a form like the one below that is sent to contacts.php and the user can dynamically add more using jquery.
<input type="text" name="name[]" /> <input type="text" name="email[]" /> <input type="text" name="name[]" /> <input type="text" name="email[]" /> <input type="text" name="name[]" /> <input type="text" name="email[]" />
If output them in php with code below
$name = $_POST['name']; $email = $_POST['account']; foreach( $name as $v ) { print $v; } foreach( $email as $v ) { print $v; }
I will get something like this:
name1name2name3email1email2email3
how can i get these arrays into something like the code below
function show_Names($n, $m) { return("The name is $n and email is $m, thank you"); } $a = array("name1", "name2", "name3"); $b = array("email1", "email2", "email3"); $c = array_map("show_Names", $a, $b); print_r($c);
so my conclusion is as follows:
Name name1 and email address email1 , thanks Name name2 and email address email2 , thank you
Name name3 and email3 , thanks
Thank you for any help or advice.
arrays php forms
thom Jul 23 '10 at 0:35 2010-07-23 00:35
source share