To optimize the storage of an IP address (v4 or v6) in a MySQL database
VARCHAR might not be the most optimal solution (as one might expect), as it uses more storage space than a byte string, which is why
VARBINARY might be a better solution. Read this article to learn more about ways to store IP addresses in a
VARBINARY field along with ways to compare the stored IP binary addresses in an SQL WHERE clause.
If you ever felt the need to custom sort an array by its keys based on an order specified in another array in PHP, you could use the short, simple and quick techniques in this article to achieve that.