note 33845 deleted from language.variables.external by danbrown
| From: | danbrown@php.net | Date: | Wed, 09 Mar 2011 14:42:46 +0000 |
| Subject: | note 33845 deleted from language.variables.external by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-177713@lists.php.net to get a copy of this message | ||
Note Submitter: cscotti@ifrance
----
In reply to the second post:
This function construct an HTTP vars array
It is useful for javascript/dom incompatibility with form_input_item[] names for checkboxes,
multiple selects, etc.
function multi_post_item() {
$array_output = array();
$raw_input_items = split("&", $_SERVER["QUERY_STRING"]);
foreach ($raw_input_items as $input_item) {
// split this item into name/value pair
$item = split("=", $input_item);
// form item name
$item_name = urldecode($item[0]);
// form item value
$item_value = urldecode($item[1]);
if (!isset($array_output[$item_name]) ) {
$array_output[$item_name] = $item_value;
}else if (!is_array($array_output[$item_name])){
$first = $item_value;
$array_output[$item_name] = array();
$array_output[$item_name][]= $first;
$array_output[$item_name][]= $item_value;
}else{
$array_output[$item_name][]= $item_value;
}
}
return $array_output;
}