Search by

atk14 / ip-matcher

michal.vojan

Small class for checking ip addresses

Package info

github.com/atk14/IpMatcher

pkg:composer/atk14/ip-matcher

Statistics

Installs: 12 425

Dependents: 2

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.2 2026-10-23 16:37 UTC

This package is auto-updated.

Last update: 2026-10-23 16:37:48 UTC


README

Tests

Small class for comparing IP addresses. One address can be compared with a single IP address or array of IPs or subnets. Works with both IPv4 and IPv6 formats.

Basic usage

Compare two IPs

IP::Match("127.0.0.1", "127.0.0.1");

Check an IP belongs to a 127.0.0.1-127.0.0.255 subnet

IP::Match("127.0.0.1", "127.0.0.1/24");

Check an IP matches at least one of addresses/subnets specified in an array

IP::Match("127.0.0.1", array("127.0.0.2", "127.0.0.1/24"));

IPv6 addresses and subnets are supported as well

IP::Match("::1", "::1");
IP::Match("21DA:00D3:0000:2F3B:02AC:00FF:FE28:9C5A", "21DA:00D3:0000:2F3B::/64");

Installation

Just use the Composer:

$ cd path/to/your/atk14/project/
$ composer require atk14/ip-matcher