Skip to content

Working with IP Addresses

Zane Hooper edited this page Mar 16, 2017 · 15 revisions

App\Ip\IpService

Create IpAddress objects out of strings.

<?php

$ips = app(App\Ip\IpService::class);
$text = implode("\n", [
    "some useless text 1.1.1.1",
    "more useless stuff 1.2.3.4, 1.2.3.4/29",
]);
$result = $ips->find($text)->map(_call('__toString'))->all();
$result = [
    "1.2.3.0/29",
    "1.1.1.1",
    "1.2.3.4",
];