note 114182 added to function.filter-input-array

From: Date: Tue, 21 Jan 2014 21:36:57 +0000
Subject: note 114182 added to function.filter-input-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-198295@lists.php.net to get a copy of this message
Note that although you can provide a default filter for the entire input array there is no way to provide a flag for that filter without building the entire definition array yourself. So here is a small function that can alleviate this hassle! <?php function filter_input_array_with_default_flags($type, $filter, $flags, $add_empty = true) { $loopThrough = array(); switch ($type) { case INPUT_GET : $loopThrough = $_GET; break; case INPUT_POST : $loopThrough = $_POST; break; case INPUT_COOKIE : $loopThrough = $_COOKIE; break; case INPUT_SERVER : $loopThrough = $_SERVER; break; case INPUT_ENV : $loopThrough = $_ENV; break; } $args = array(); foreach ($loopThrough as $key=>$value) { $args[$key] = array('filter'=>$filter, 'flags'=>$flags); } return filter_input_array($type, $args, $add_empty); } ?> ---- Server IP: 72.52.91.14 Probable Submitter: 72.52.91.14 ---- Manual Page -- http://php.net/manual/en/function.filter-input-array.php Edit -- https://master.php.net/note/edit/114182 Del: integrated -- https://master.php.net/note/delete/114182/integrated Del: useless -- https://master.php.net/note/delete/114182/useless Del: bad code -- https://master.php.net/note/delete/114182/bad+code Del: spam -- https://master.php.net/note/delete/114182/spam Del: non-english -- https://master.php.net/note/delete/114182/non-english Del: in docs -- https://master.php.net/note/delete/114182/in+docs Del: other reasons-- https://master.php.net/note/delete/114182 Reject -- https://master.php.net/note/reject/114182 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#198295) next »