Dimensional Posted February 26, 2010 Share Posted February 26, 2010 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 More sharing options...
ialsoagree Posted February 26, 2010 Share Posted February 26, 2010 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. Link to comment https://forums.phpfreaks.com/topic/193497-variable-not-maintaining-values/#findComment-1018724 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.