src/ClientIp.php
private function getForwardedHeaderIp(string $header)
    {
        foreach (array_reverse(array_map('trim', explode(',', strtolower($header)))) as $values) {
            foreach (array_reverse(array_map('trim', explode(';', $values))) as $directive) {
                if (strpos($directive, 'for=') !== 0) {
                    continue;
                }

                $ip = trim(substr($directive, 4));

                if (self::isValid($ip) && !$this->isInProxiedIps($ip)) {
                    return $ip;
                }
            }
        }
    }
private function getForwardedHeaderIp(string $header)
    {
        foreach (array_reverse(array_map('trim', explode(',', strtolower($header)))) as $values) {
            foreach (array_reverse(array_map('trim', explode(';', $values))) as $directive) {
                if (strpos($directive, 'for=') !== 0) {
                    continue;
                }

                $ip = trim(substr($directive, 4));

                if (self::isValid($ip) && !$this->isInProxiedIps($ip)) {
                    return $ip;
                }
            }
        }
    }
private function getForwardedHeaderIp ( string $ header ) { foreach ( array_reverse ( array_map ( 'trim' , explode ( ',' , strtolower ( $ header ) ) ) ) as $ values ) { foreach ( array_reverse ( array_map ( 'trim' , explode ( ';' , $ values ) ) ) as $ directive ) { if ( strpos ( $ directive , 'for=' ) !== 0 ) { continue ; } $ ip = trim ( substr ( $ directive , 4 ) ) ; if ( self :: isValid ( $ ip ) && ! $ this -> isInProxiedIps ( $ ip ) ) { return $ ip ; } } } }
Returns the first valid ip found in the Forwarded or X-Forwarded header.

@return string|null
Returns the first valid ip found in the Forwarded or X - Forwarded header .