Double parsing variables?

Reply

Join Date: Nov 2004
Posts: 1
Reputation: alexruimy is an unknown quantity at this point 
Solved Threads: 0
alexruimy alexruimy is offline Offline
Newbie Poster

Double parsing variables?

 
0
  #1
Nov 8th, 2004
Hi guys, I'm Alex. I'm a complete n00b to the world of PHP and am glad that y'all have support available here.

Anyway, I'm unofficially doing tech stuff for a magazine and I'm working on a code to order subscriptions. I'm having a problem with variables in a loop I'm using...

So I have a bunch of forms that are being generated from a loop, based on a number ($num) that a customer chooses (we're talking about shipping addresses). This form, with however many generated shipping addresses, is then sent through a payment processing script and upon verification (ideally), the script will send out $num of emails to our distributer containing the shipping information for each subscription.

I wrote the loop so the forms that it generates are called "Firstname1" and "Firstname2" for example.

My problem is, in writing the loop to be run post-positive-verification, can I have the PHP parse its own variables?

Something like this:

  1. case "1":
  2. for($i = 0; $i < $num; $i++) {
  3. mail ("Alex@worthwhilemag.com","Worthwhile Subscription Purchase",
  4. "A Worthwhile Subscription has been ordered for:
  5. \n$firstname$i $lastname$i\n$address$i\n$city$i, $state$i $zip$i");
  6. }
The double variables are what I feel is throwing me off. Anyone know if this is possible or I'm missing something?

I don't think I articulated this too well, btw...
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 14
Reputation: fpepito is an unknown quantity at this point 
Solved Threads: 1
fpepito fpepito is offline Offline
Newbie Poster

Re: Double parsing variables?

 
0
  #2
Nov 8th, 2004
hello alexruimy,

Try to use array

fpepito

try this example: http://www.fpepito.org/php/test3.php

[PHP]
<?

$customers = array(
array("Firstname", "lastname", "address", "city", "state", "zip", "e-mail@hotmail.com", "url"),
array("Francis", "Goncalves", "my adress", "Paris", "Ile-de-France", "75001", "test@hotmail.com", "http://ascejudo.mine.nu"),
array("Francisco", "Goncalves Andrade", "my address", "Lisbon", "Estremedura", "60000", "test@hotmail.com", "http://www.fpepito.org/")
);

#########

function read_customer($customers) {

#read each Customer on the list of Customers
while (list ($key, $customer) = each ($customers)) {
echo "send e-mail to $customer[6]<BR>\n";
echo "A Worthwhile Subscription has been ordered for: \n".$customer[0]." ".$customer[1]."\n".$customer[2]."\n".$customer[3].", ".$customer[4];
echo "<HR>\n";
}
}

read_customer($customers);
?>
[/PHP]
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 2660 | Replies: 1
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC