lindm Posted September 23, 2009 Share Posted September 23, 2009 Need help to create a function that does the below, but independent of the number of variables. Basic function: function test($field1,$field2) {if (($field1=="0"&&$field2=="0")||($field1==''&&$field2=='')) return 'all fields are null';} Should be something like: function test($fields) {if (all fields =="0")||(all fields =="")) return 'all fields are null';} the function should work the same for row(field1,field2,field3) or row(field1,field2,field3,field4,field5,field6) Possible? Quote Link to comment https://forums.phpfreaks.com/topic/175276-solved-loop-through-function-variables-no-matter-the-number-of-variables/ Share on other sites More sharing options...
nuttycoder Posted September 23, 2009 Share Posted September 23, 2009 you could pass the vars as an array then loop through the array inside the function Quote Link to comment https://forums.phpfreaks.com/topic/175276-solved-loop-through-function-variables-no-matter-the-number-of-variables/#findComment-923783 Share on other sites More sharing options...
PFMaBiSmAd Posted September 23, 2009 Share Posted September 23, 2009 http://www.php.net/manual/en/function.func-get-args.php Quote Link to comment https://forums.phpfreaks.com/topic/175276-solved-loop-through-function-variables-no-matter-the-number-of-variables/#findComment-923792 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.