Support Forums

Full Version: Simple IP verification
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This is one of the first things I ever made, it is quite useful and a bit messy.

PHP has a very powerful library of array functions. Specifically, the in_array () function would apply nicely here. Instead of looping through the array you could simply call that function.

Also, in a situation where you're looping through a set looking for a positive flag ($access in this case), it's best to default the flag to false and then switch it to true if the condition necessitates it. This prevents you from having to write wasteful ELSE statements and thus improves efficiency.
(11-21-2010, 11:13 PM)Disease Wrote: [ -> ]PHP has a very powerful library of array functions. Specifically, the in_array () function would apply nicely here. Instead of looping through the array you could simply call that function.

Also, in a situation where you're looping through a set looking for a positive flag ($access in this case), it's best to default the flag to false and then switch it to true if the condition necessitates it. This prevents you from having to write wasteful ELSE statements and thus improves efficiency.

I know, I have rewritten one for personal use. This is as I said, the first script I made, no modifications. It's quite old.
Quite basic and useful too.
Yeah basic stuff but nice of you to contribute.
That gave me an excellent idea, I made make something similar to this.