muppet77 Posted September 29, 2014 Share Posted September 29, 2014 is there an easy way to make all variables equal to zero (as opposed to empty) at the end of a loop? rather than $a =0; $b=0; etc etc as i have hundreds and hundreds of the things and need to reset them all to equal a value of zero. thank you in advance. Quote Link to comment https://forums.phpfreaks.com/topic/291354-make-all-variables-equal-to-zero/ Share on other sites More sharing options...
requinix Posted September 29, 2014 Share Posted September 29, 2014 If you're using a ton of variables then you're going to need a ton of =0s. Any particular reason you have to zero them out? What's your code, in case there is an easy way? Quote Link to comment https://forums.phpfreaks.com/topic/291354-make-all-variables-equal-to-zero/#findComment-1492409 Share on other sites More sharing options...
Psycho Posted September 29, 2014 Share Posted September 29, 2014 Hundreds of variables? I doubt you really need all of those and it could be streamlines with better code. Otherwise, you should use array variables. E.g. $vars['a'], $vars['b'], etc. Then, at the very least, you could run a loop to zero all of them out or have a template array to set the initial state. But, as requinix stated, it would be nice to see the code as we can probably find a better solution. Quote Link to comment https://forums.phpfreaks.com/topic/291354-make-all-variables-equal-to-zero/#findComment-1492410 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.