Php URL $_ GET add up?

want to check
I want the network address get to add up
for example, the existing network address is

region=abc&status=1

when I may enter another web address
I want him to add & xxx=1
but will not wash out the previous GET parameters

region=abc&status=1&xxx=1

No matter how many GET parameters are added before, but the duplicates are not added
so I don"t need to redefine the GET parameters.
as long as there are not the same parameters on the network address, add up
. What code can this code do?

check
, but if the network address does not have any parameters, then
it can automatically identify, that is, change to

.
xxx.php?xxx=xxx

instead of &
unless there is already ? , it will be &

.
Mar.04,2021

Hello this question is very simple:
1) generally this requirement is used in the business of product list criteria filtering
for example: shoes I want to choose red, number 42
2) use js to get the current url, first and then splice it directly to it
code is as follows:
var host = window.location.href; / / get url
window.location.href = url+ "/ xxx/1"; / / stitching url
solving problems


http_build_query


// 
function parse_url(url)
{
    var a = document.createElement('a');
    a.href = url;
    return {
        source:url,
        protocol:a.protocol.replace(':', ''),
        host:a.hostname,
        port:a.port,
        query:a.search,
        params:(function(){
            var ret = {}, seg = a.search.replace(/^\?/, '').split('&'), len = seg.length, i = 0, s;
            for(;i<len;iPP) {
                if(!seg[i]) {
                    continue;
                }
                s = seg[i].split('=');
                ret[s[0]] = s[1];
            }
            return ret;
        })(),
        file:(a.pathname.match(/\/([^\/?-sharp]+)$/i) || [, ''])[1],
        hash:a.hash.replace('-sharp', ''),
        path:a.pathname.replace(/^([^\/])/, '/$1'),
        segments:a.pathname.replace(/^\//, '').split('/')
    };
}
  1. add all links to click events through js
  2. The current page address and the target page address are resolved through parse_url in the
  3. event
  4. request parameters of the two addresses after merging and parsing
  5. stitching the final jump address
  6. Block default behavior

if you want to pass php, you have to generate a link through a function

  1. resolve the target link
  2. merge parameters
  3. return the final access link

you can try this

$url = 'xxx.php?xxx=xxx';
$params = [
    'region' => 'abc',
    'status' => 1
];
$urlParams = http_build_query($params);

if(strpos($url, '?')){
    echo $url.$urlParams;
}else{
    echo $url.'?'.$urlParams;
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b31e81-2b31b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b31e81-2b31b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?