Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save DrARoberts/6774270cc1fb47ce59c8d4c247109c12 to your computer and use it in GitHub Desktop.
Save DrARoberts/6774270cc1fb47ce59c8d4c247109c12 to your computer and use it in GitHub Desktop.
$odds = $inner = array();
foreach($_GET as $key => $values) {
if (!isset($inner[$key])) {
$inner[$key] = $values;
} elseif (!in_array(!is_array($values)?$values:md5(json_encode($values, true)), array_keys($odds[$key]))) {
if (is_array($values)) {
$odds[$key][md5(json_encode($inner[$key] = $values, true))] = $values;
} else {
$odds[$key][$inner[$key] = $values] = "$values--$key";
}
}
}
foreach($_POST as $key => $values) {
if (!isset($inner[$key])) {
$inner[$key] = $values;
} elseif (!in_array(!is_array($values)?$values:md5(json_encode($values, true)), array_keys($odds[$key]))) {
if (is_array($values)) {
$odds[$key][md5(json_encode($inner[$key] = $values, true))] = $values;
} else {
$odds[$key][$inner[$key] = $values] = "$values--$key";
}
}
}
foreach(parse_url('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].(strpos($_SERVER['REQUEST_URI'], '?')?'&':'?').$_SERVER['QUERY_STRING'], PHP_URL_QUERY) as $key => $values) {
if (!isset($inner[$key])) {
$inner[$key] = $values;
} elseif (!in_array(!is_array($values)?$values:md5(json_encode($values, true)), array_keys($odds[$key]))) {
if (is_array($values)) {
$odds[$key][md5(json_encode($inner[$key] = $values, true))] = $values;
} else {
$odds[$key][$inner[$key] = $values] = "$values--$key";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment