PHP फ़िल्टर_इनपुट_एरे () फ़ंक्शन
उदाहरण
तीन POST वैरिएबल को फ़िल्टर करने के लिए filter_input_array() फ़ंक्शन का उपयोग करें। प्राप्त POST चर नाम, आयु और ई-मेल है:
<?php
$filters = array (
"name" => array ("filter"=>FILTER_CALLBACK,
"flags"=>FILTER_FORCE_ARRAY,
"options"=>"ucwords"
),
"age" => array ( "filter"=>FILTER_VALIDATE_INT,
"options"=>array("min_range"=>1,"max_range"=>120)
),
"email" => FILTER_VALIDATE_EMAIL
);
print_r(filter_input_array(INPUT_POST, $filters));
?>
उपरोक्त कोड का आउटपुट होगा:
परिभाषा और उपयोग
फ़िल्टर_इनपुट_एरे () फ़ंक्शन बाहरी चर (जैसे फॉर्म इनपुट से) प्राप्त करता है और वैकल्पिक रूप से उन्हें फ़िल्टर करता है।
यह फ़ंक्शन फ़िल्टर_इनपुट () को कई बार कॉल करने के बजाय कई मानों को पुनः प्राप्त/फ़िल्टर करने के लिए उपयोगी है।
वाक्य - विन्यास
filter_input_array(type, definition, add_empty)
पैरामीटर मान
Parameter | Description |
---|---|
type | Required. The input type to check for. Can be one of the following:
|
definition | Optional. Specifies an array of filter arguments. A valid array key is a variable name, and a valid value is a filter name or ID, or an array specifying the filter, flags and options. This parameter can also be a single filter name/ID; then all values in the input array are filtered by the specified filter |
add_empty | Optional. A Boolean value. TRUE adds missing keys as NULL to the return value. Default value is TRUE |
टेक्निकल डिटेल
प्रतिलाभ की मात्रा: | सफलता पर चर के मूल्यों के साथ एक सरणी, विफलता पर FALSE |
---|---|
पीएचपी संस्करण: | 5.2+ |
पीएचपी चेंजलॉग: | PHP 5.4 - add_empty पैरामीटर जोड़ा गया था |
❮ पूर्ण PHP फ़िल्टर संदर्भ