Or maybe that looks better?

        $clientIp = $ip;

        while (list( , $trustedProxy) = each($trustedProxies)) {
            if (IpUtils::checkIp($clientIp, $trustedProxy)) {
                if (!$clientIps) {
                    return $clientIp;
                }

                $clientIp = array_pop($clientIps);
                reset($trustedProxies);
            }
        }