Re: [PHP] Cause of undefined offset notice
> On Nov 18, 2017, at 6:08 AM, AshleySheridan <ash@xxxxxxxxxxxxxxxxxxxx> wrote:
> Please never, never use the `@` to suppress error messages.
Removed. I forgot they were even there. Thanks.
> As to your problem, you haven't said what you're feeding into this.
The script reads files that contain lists of either full IP addresses or CIDR formatted IP's and will compare the remote IP to see if it's banned.
> Have you tried any sort of debugging yet to see why `$base` doesn't
> have 3 '.' characters?
Yes, and I found the problem line.
> This probably could be written a bit better. Exploding strings into
> parts (where you really only want one substring) is expensive in terms
> of CPU cycles, compared to a straight up substring.
I was afraid of that. Hopefully I can figure out how to make this better.
> Also, have you considered converting the whole IP address into a single
> `ip2long()` will
> do this ... It will be far faster than what you're doing,
> and make the code a lot simpler and easier to read/manage.
This morning I found a blog post about this that seems to handle any situation:
With my limited knowledge on this subject, it seems to me to be a good solution. Thoughts?
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php