Create an array of function arguments not equal to NULL?

Nonickname

New Member
I'll start with explaining what my end goal is as there may be better solutions to it.I have a function called \[code\]updateUser\[/code\] which accepts the following parameters:\[code\]function updateUser($password = NULL, $name = NULL, $lastname = NULL, $age = NULL, $email = NULL, $relation = NULL)\[/code\]As you can see I've set them to NULL, so if they aren't passed through the function they become blank. Right? (I hope I got that right)The problem is that each of those arguments (which are passed) contains info for a user that's going to be sent in to a database, and I only want to include the passed variables in the query as I don't want to set the ones that are not passed to (blank) in the database.And so I came up with the idea to take all the passed arguments and shove them into an array. And then loop through every item in the array and generate a string like:\[code\]$string = "$password, $email";\[/code\]So, any suggestions? As I said, I don't have to use this method if there is another better way to fix this issue.Thanks in advandce!
 
Back
Top