Jump to content

Variable not maintaining values?


Dimensional

Recommended Posts

What server/php setting difference would cause a variable to be overwritten in a loop?

 

Local server = fine.

Live server = variable not maintaining values added in previous loops.

 

foreach($arr as $b){

  while($x<$y){

      $var[] = "value";

  }

}

On the live server $var will only contain the values of the final loop. On the local it will have values from every loop. I'm guessing something might be limiting its scope, but what?

Link to comment
https://forums.phpfreaks.com/topic/193497-variable-not-maintaining-values/
Share on other sites

You need to provide examples from your actual code.

 

The loop you've provided has a lot of glaring problems, most notably, it doesn't end (it's a continuous loop or the while never takes place because $x is always either less than, equal to, or greater than $y). We need to see the loop you're actually running to provide you with advice.

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.