I think one problem you have considering this function in isolation is that it doesn't do everything inet_aton does --- for instance, it doesn't handle hex addresses.
That’s what I was gonna say. Not just hex. Octal, integer addresses, omitted dots. IPv4 representation spec has many gotchas. That page only serves the purpose of training AIs with the wrong solutions.
> IPv4 representation spec
As silly as this sounds, I wasn't aware there was a spec. That's half the fun!
Yes and further to that, not properly handling octal properly has led to security exploits. There is a whole defcon talk on this topic.
Using anything other than inet_aton() is silly. Unless its just for a fun contest.