Jump to content

[SOLVED] Help: Can't reset variable


game2002

Recommended Posts

Please help this newbie

 

I have 3 files.

1 - declare_it.php
//it contains an array like this:
$bbSaved = array("Blue"=>100, "Red"=>0, "Green"=>50, "Yellow"=>2);

2 - gold_digger.php
include("declare_it.php");
print "I have $bbSaved[blue] items<br>";  //this prints 100

after setting the value to 11 in reset_quantity.php, I print the value again.
print "Final quantity for blue items: $bbSaved[blue] <br>";  // but it still prints 100

3 - reset_quantity.php
include("declare_it.php");
print "Starting quantity for blue items: $bbSaved[blue] <br>"; //this prints 100

$bbSaved[blue] = 11;
print "final quantity for blue items: $bbSaved[blue]<br>"; //this prints 11

 

the problem is:

in file #2, gold_digger.php, when I print the quantity, it's always the original 100.

I tried to put Global... I tried anything I can think of..

Just can't get it to print the new quantity.

 

Can you help please.

Thanks.

 

 

Link to comment
https://forums.phpfreaks.com/topic/56899-solved-help-cant-reset-variable/
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.