function search_api_federated_solr_parse_str_multiple in Search API Federated Solr 7.3
Same name and namespace in other branches
- 7.2 search_api_federated_solr.module \search_api_federated_solr_parse_str_multiple()
Parses a querystring with support for multiple keys not using array[] syntax. @see: http://php.net/manual/en/function.parse-str.php#76792
Parameters
$str: The querystring from the request object.
Return value
array Array of querystring params and their values.
1 call to search_api_federated_solr_parse_str_multiple()
- search_api_federated_solr_proxy in ./
search_api_federated_solr.proxy.inc - The proxy controller.
File
- ./
search_api_federated_solr.module, line 878 - search_api_federated_solr.module Contains hook implementations for the Federated Solr Search API Module.
Code
function search_api_federated_solr_parse_str_multiple($str) {
# result array
$arr = [];
# split on outer delimiter
$pairs = explode('&', $str);
# loop through each pair
foreach ($pairs as $i) {
# split into name and value
if (strpos($i, '=') !== FALSE) {
list($name, $value) = explode('=', $i, 2);
}
else {
continue;
}
# if name already exists
if (isset($arr[$name])) {
# stick multiple values into an array
if (is_array($arr[$name])) {
$arr[$name][] = $value;
}
else {
$arr[$name] = array(
$arr[$name],
$value,
);
}
}
else {
$arr[$name] = $value;
}
}
# return result array
return $arr;
}