Permalink
Browse files

change while loops with foreach

  • Loading branch information...
1 parent 31311e0 commit 03ba21ce4aee79a708b6c77f377873f23e92dfef @acidvertigo acidvertigo committed Aug 17, 2011
Showing with 7 additions and 7 deletions.
  1. +7 −7 catalog/shopping_cart.php
@@ -40,10 +40,11 @@
<?php
$any_out_of_stock = 0;
$products = $cart->get_products();
- for ($i=0, $n=sizeof($products); $i<$n; $i++) {
+ $n=sizeof($products);
+ for ($i=0; $i<$n; $i++) {
// Push all attributes information in an array
if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
- while (list($option, $value) = each($products[$i]['attributes'])) {
+ foreach ($products[$i]['attributes'] as $option => $value ) {
echo tep_draw_hidden_field('id[' . $products[$i]['id'] . '][' . $option . ']', $value);
$attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix
from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa
@@ -70,7 +71,8 @@
<?php
- for ($i=0, $n=sizeof($products); $i<$n; $i++) {
+ $n=sizeof($products);
+ for ($i=0; $i<$n; $i++) {
echo ' <tr>';
$products_name = '<table border="0" cellspacing="2" cellpadding="2">' .
@@ -88,8 +90,7 @@
}
if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
- reset($products[$i]['attributes']);
- while (list($option, $value) = each($products[$i]['attributes'])) {
+ foreach ($products[$i]['attributes'] as $option => $value) {
$products_name .= '<br /><small><i> - ' . $products[$i][$option]['products_options_name'] . ' ' . $products[$i][$option]['products_options_values_name'] . '</i></small>';
}
}
@@ -143,8 +144,7 @@
<p align="right" style="clear: both; padding: 15px 50px 0 0;"><?php echo TEXT_ALTERNATIVE_CHECKOUT_METHODS; ?></p>
<?php
- reset($initialize_checkout_methods);
- while (list(, $value) = each($initialize_checkout_methods)) {
+ foreach ($initialize_checkout_methods as $value) {
?>
<p align="right"><?php echo $value; ?></p>

0 comments on commit 03ba21c

Please sign in to comment.