PHP code example of nyholm / append-query-string
1. Go to this page and download the library: Download nyholm/append-query-string library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nyholm / append-query-string example snippets
$url = 'https://nyholm.tech?example=yes';
$queryString = http_build_query(['foo'=>'bar']);
$result = append_query_string($url, $queryString);
echo $result;
// https://nyholm.tech?example=yes&foo=bar
$result = $url . $queryString;
$url = 'https://nyholm.tech?foo=x&a=1';
$queryString = http_build_query(['a'=>'2']);
$result = append_query_string($url, $queryString, APPEND_QUERY_STRING_IGNORE_DUPLICATE);
echo $result;
// https://nyholm.tech?foo=x&a=1&a=2
$url = 'https://nyholm.tech?foo=x&a=1';
$queryString = http_build_query(['a'=>'2']);
$result = append_query_string($url, $queryString, APPEND_QUERY_STRING_REPLACE_DUPLICATE);
echo $result;
// https://nyholm.tech?foo=x&a=2
$url = 'https://nyholm.tech?foo=x&a=1';
$queryString = http_build_query(['a'=>'2']);
$result = append_query_string($url, $queryString, APPEND_QUERY_STRING_SKIP_DUPLICATE);
echo $result;
// https://nyholm.tech?foo=x&a=1