So I need to store IP addresses in database, but storing them as stings is not very efficient and not very convenient for my purpose.
So… How can I convert ip into integer in php with as less processing as possible because it will be done millions of times a day.
And of course how can I convert back from integet to ip?
I know this can be googled and there’s some easy solutions – but I’m asking for the fastest way, not just for “do X and you get Y” because it’s actually pretty easy task.
Use
ip2long()andlong2ip(). They are the fastest you can find in PHP, because they are just built on top of the corresponding C functions.