public static function reverseIpv6(string $ip, bool $appendSuffix = true): string
    {
        try {
            $ip = self::expandIpv6($ip);
        } catch (\InvalidArgumentException $e) {
            $ip = self::expandIncompleteIpv6($ip);
        }

        $ip = str_replace(':', '', $ip);
        $ip = strrev($ip);
        $ip = implode('.', str_split($ip));
        $ip .= $appendSuffix ? '.ip6.arpa.' : '';

        return $ip;
    }
public static function reverseIpv6(string $ip, bool $appendSuffix = true): string
    {
        try {
            $ip = self::expandIpv6($ip);
        } catch (\InvalidArgumentException $e) {
            $ip = self::expandIncompleteIpv6($ip);
        }

        $ip = str_replace(':', '', $ip);
        $ip = strrev($ip);
        $ip = implode('.', str_split($ip));
        $ip .= $appendSuffix ? '.ip6.arpa.' : '';

        return $ip;
    }
public static function reverseIpv6 ( string $ ip , bool $ appendSuffix = true ) : string { try { $ ip = self :: expandIpv6 ( $ ip ) ; } catch ( \ InvalidArgumentException $ e ) { $ ip = self :: expandIncompleteIpv6 ( $ ip ) ; } $ ip = str_replace ( ':' , '' , $ ip ) ; $ ip = strrev ( $ ip ) ; $ ip = implode ( '.' , str_split ( $ ip ) ) ; $ ip .= $ appendSuffix ? '.ip6.arpa.' : '' ; return $ ip ; }
Creates a reverse IPv6 address.

E.g. 2001:db8::567:89ab -> b.a.9.8.7.6.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.

@param string $ip           A full or partial IPv6 address
@param bool   $appendSuffix Whether or not to append ".ip6.arpa.' suffix.

@return string The reversed address appended with ".ip6.arpa."
Creates a reverse IPv6 address .