Re: initialize variables

From: Date: Tue, 14 Jan 2003 06:13:23 +0000
Subject: Re: initialize variables
References: 1 2  Groups: php.windows 
Request: Send a blank email to php-windows+get-17846@lists.php.net to get a copy of this message
01132003 2203 CST I thought I was starting to get it until I got to the last section. Original code from the book: <?php $total = 0; echo "Your order was for the following:<br><br>"; echo "Entree: $Course1<br>"; echo "Dessert: $ListBox2<br><br>"; foreach (array($Course1, $ListBox2) as $val) { if (ereg("[0-9]+", $val, $reg)) $total += $reg[0]; } echo "TOTAL BILL = $" . $total . "<br>"; ?> I was brave and tried to make many changes but none worked. This is where I ended up: <?php $total= 0; echo 'Your order was for the following:<br><br>'; echo 'Entree: "' . $_POST . $Course1 . '"<br>'; echo 'Dessert: "' . $_POST . $ListBox2 . '"<br><br>'; foreach (array($Course1, $ListBox2) as $val) { if (ereg('[0-9]+', $val, $regs)) $total += $regs[0]; } echo 'TOTAL BILL = $"' . $total . '"<br>'; ?> The output for this last code is: Your order was for the following: Entree: Array Dessert: Array TOTAL BILL = $"0" Enlighten me. Im trying hard to understand where to put things together. Thanks Wade Sean Malloy wrote:
String concatenation? Its a way ogf combining strings into one. $string = 'Hello'; $string = $string . ' World'; echo $string; would output 'Hello World' -----Original Message----- From: Wade [mailto:wade@wadesmart.com] Sent: Tuesday, 14 January 2003 4:02 PM To: php-windows@lists.php.net Subject: Re: [PHP-WIN] initialize variables 01132003 2059 CST Sean, Thats a new one for me. In the line below, what does the " ' . $Entrees[0] . ' "> do? The " . ", do they have some value or do they negate something? echo '<option value="' . $Entrees[0] . '">' . $Entrees[0] . '</option>'; Wade


« previous php.windows (#17846) next »