Jump to content

scope of arrays


ivytony

Recommended Posts

I have below question about the scope of arrays.

 

<?php

$sale = array('One' => 200,

                  'Two' => 300,

                  'Three' => 400,

                  'Five' => 500,

                );

 

$taxrate = array('One' => 0.067,

                  'Two' => 0.087,

                  'Three' => 0.080,

                  'Five' => 0.081,

                );

 

foreach($sale as $key => $value) {

      $tax = $taxrate[$key] * $sale[$key];

      echo '$tax is: '. $tax.'|  $sale is: '. $sale[$key]. '<br />';

 

}

?>

 

This generates correct results from the $key.

 

However, this below array doesn't give correct results.

Link to comment
https://forums.phpfreaks.com/topic/95324-scope-of-arrays/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.