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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.