Requests_IPv6::split_v6_v4() WordPress Method

The Requests_IPv6::split_v6_v4() method is used to split an IPv6 address into its IPv6 and IPv4 components. This is useful for determining whether an address is IPv6-only or dual-stack.

Requests_IPv6::split_v6_v4( string $ip ) #

Splits an IPv6 address into the IPv6 and IPv4 representation parts


Description

RFC 4291 allows you to represent the last two parts of an IPv6 address using the standard IPv4 representation

Example: 0:0:0:0:0:0:13.1.68.3 0:0:0:0:0:FFFF:129.144.52.38


Top ↑

Parameters

$ip

(string)(Required)An IPv6 address


Top ↑

Return

(string[]) [0] contains the IPv6 represented part, and [1] the IPv4 represented part


Top ↑

Source

File: wp-includes/Requests/IPv6.php

	protected static function split_v6_v4($ip) {
		if (strpos($ip, '.') !== false) {
			$pos       = strrpos($ip, ':');
			$ipv6_part = substr($ip, 0, $pos);
			$ipv4_part = substr($ip, $pos + 1);
			return array($ipv6_part, $ipv4_part);
		}
		else {
			return array($ip, '');
		}
	}

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.