note 103503 deleted from function.filter-input by danbrown
| From: | danbrown@php.net | Date: | Sat, 16 Apr 2011 18:05:17 +0000 |
| Subject: | note 103503 deleted from function.filter-input by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-178915@lists.php.net to get a copy of this message | ||
Note Submitter: web at bartwell dot ru
----
Easy way to check array with IP-addresses:
<?
if(in_array(false, filter_input(INPUT_POST, 'ip', FILTER_VALIDATE_IP,
FILTER_REQUIRE_ARRAY))) {
echo 'Error!';
} else {
echo 'All IP addresses is valid';
}
?>
<form action="file.php" method="post">
<input name="ip[]" type="text" value="192.168.1.1"/><br/>
<input name="ip[]" type="text" value="192.168.1.2"/><br/>
<input name="ip[]" type="text" value="192.168.1.3"/><br/>
<input name="ip[]" type="text" value="192.168.1.4"/><br/>
<input name="ip[]" type="text" value="192.168.1.5"/><br/>
<input name="ip[]" type="text" value="192.168.1.6"/><br/>
<input type="submit" value="Send"/>
</form>