foreach函数仅显示最后一个值

when i wanna get all value to check with current user ip it just check last ip with current user , i don't know why before values doesnt check.

i fill IPs in a textarea like this : 176.227.213.74,176.227.213.78

                elseif($maintenance_for == '2') {
                $get_ips = $options['ips'];
                $explode_ips = explode(',',$get_ips);
                foreach ($explode_ips as $ips) {
                    if($ips == $_SERVER["REMOTE_ADDR"]){
                        $maintenance_mode = true;
                    }
                    else {
                        $maintenance_mode = false;
                    }
                }
            }

If you found the right value, you wan't to BREAK out of the foreach loop

$get_ips = $options['ips'];
$explode_ips = explode(',', $get_ips);
foreach($explode_ips as $ips) {
    if ($ips == $_SERVER["REMOTE_ADDR"]) {
        $maintenance_mode = true;
        break; // If the IP is right, BREAK out of the foreach, leaving $maintenance_mode to true
    } else {
        $maintenance_mode = false;
    }
}

yes, you will always override it. Its better to set a default and only set it once: (Edit: added @Mathlight's answer, the break, in my solution as he suggested)

$maintenance_mode = false;
foreach ($explode_ips as $ips) {
    if($ips == $_SERVER["REMOTE_ADDR"]){
        $maintenance_mode = true;
        break;
    }
}

EDIT : another solution for the record, for the points of a oneliner

$maintenance_mode = in_array($_SERVER["REMOTE_ADDR"], $explode_ips);