[code] Can you do this better?

Sixth

Saturnine
Joined
Apr 6, 2002
Posts
1,334
I understand that this is pushing the scope of the general board rather far - still, no more off topic than the general debates, perhaps. I hope the tag helps.

This looks sloppy to me. Can anyone offer up something more tidy?

PHP:
if ($domain_one_lv=="")
	{ $domain_one="-1"; }
if ($domain_two_lv=="")
	{ $domain_two="-1"; }
if (!is_numeric($brd))
	{ $brd="-1"; }
if (!is_numeric($clr))
	{ $clr="-1"; }
if (!is_numeric($drd))
	{ $drd="-1"; }
if (!is_numeric($pal))
	{ $pal="-1"; }
if (!is_numeric($rgr))
	{ $rgr="-1"; }
if (!is_numeric($sor))
	{ $sor="-1"; }
if (!is_numeric($wiz))
	{ $wiz="-1"; }
if (!is_numeric($domain_one_lv))
	{ $domain_one_lv="-1"; }
if (!is_numeric($domain_two_lv))
	{ $domain_two_lv="-1"; }
 
Guru said:
There is no context there... but you might consider making your class an (associative) array:

I released that bad right after I posted. I shouldn't try and code, drink, lit and watch the Outer Limits all at once.

I considered the array approach but it's just a quickie to take input from a form and throw it into the database. I could name the input fields array[1], array[2], array[3] etc and then throw together a walkthru function - but it struck me as overkill.

With hindsight, I'm happy with what's there. If the code ever gets used elsewhere in the feature then I'll function it.

Thanks for your input.
 
Code:
if ($user[handle] == "Siren") {
    fuckhersilly();
    getherphonenumber();
else if ($user[handle] == "Killer Muffin") {
    fuckhersilly();
    destroyevidence();
}

Fatal exception error. No such user.
 
Back
Top