note 30866 modified in language.variables.external by danbrown
| From: | danbrown@php.net | Date: | Wed, 09 Mar 2011 14:44:04 +0000 |
| Subject: | note 30866 modified in language.variables.external by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-177715@lists.php.net to get a copy of this message | ||
This function takes a recurring form item from php://input and loads it into an array - useful for
javascript/dom incompatibility with form_input_item[] names for checkboxes, multiple selects, etc.
The fread maxes out at 100k on this one. I guess a more portable option would be pulling in
ini_get('post_max_size') and converting it to an integer.
<?php
function multi_post_item($input_item_name) {
$array_output = array();
$in_handle = fopen("php://input", "r");
$raw_input_items = split("&", urldecode(fread($in_handle, 100000)));
foreach ($raw_input_items as $input_item) {
// split this item into name/value pair
$item = split("=", $input_item);
// form item name
$item_name = $item[0];
// form item value
$item_value = $item[1];
if ($item_name == $input_item_name) {
$array_output[] = $item_value;
}
}
return $array_output;
}
?>
--was--
This function takes a recurring form item from php://input and loads it into an array - useful for
javascript/dom incompatibility with form_input_item[] names for checkboxes, multiple selects, etc.
The fread maxes out at 100k on this one. I guess a more portable option would be pulling in
ini_get('post_max_size') and converting it to an integer.
function multi_post_item($input_item_name) {
$array_output = array();
$in_handle = fopen("php://input", "r");
$raw_input_items = split("&", urldecode(fread($in_handle, 100000)));
foreach ($raw_input_items as $input_item) {
// split this item into name/value pair
$item = split("=", $input_item);
// form item name
$item_name = $item[0];
// form item value
$item_value = $item[1];
if ($item_name == $input_item_name) {
$array_output[] = $item_value;
}
}
return $array_output;
}
http://php.net/manual/en/language.variables.external.php