I want to add GET parameters to URLs that may and may not contain GET parameters without repeating ? or &.
?
&
Example:
If I want t
In case you are using WordPress you can simply use
add_query_args(['sort' => 'asc'], 'http:/example.com/?search=news')
Docs https://developer.wordpress.org/reference/functions/add_query_arg/