[thelist] building a dynamic variable in php
shawn allen
shawn at alterior.net
Mon Jan 13 12:38:01 CST 2003
quoth Tom Dell'Aringa:
> I have a send to friend list where they can send a link to 10 friends.
>
> for($i = 1; $i<=10; $i++)
> {
> $var = "mail" . $i;
> ${$var} = $_POST[$i];
>
> $body = "body of email";
>
> mail(${$var}, "From $personA/$personB", $body, "From:
> $email\r\nReply-To: $email\r\n");
> }
I don't get it. Why not stick $_POST[$i] right into your mail()
call? In fact, why not pear it down to:
foreach ($_POST as $email) {
mail($email, ...);
}
You'd probably be better off isolating the addresses into their own
array within $_POST by naming the form inputs differently, though:
<?php for ($i = 1; $i < 11; $i++) { ?>
<input type="text" name="address[<?php echo $i; ?>]" />
<?php } ?>
Then looping on $_POST['address']... Just a thought.
--
shawn allen
mailto://shawn@alterior.net
phone://415.577.3961
http://alterior.net
aim://shawnpallen
More information about the thelist
mailing list