Trim Query Parameters From URL

There are several ways to solve this problem. These are the two most prominent way to achieve this.

1. Php way: Parse, trim and rebuild

https://maxchadwick.xyz/blog/stripping-a-query-parameter-from-a-url-in-php

2. Using preg_replce

https://davidwalsh.name/php-remove-variable

First one is the easy way to do it and also do not require any external library.

On the other hand, the second one is bit lengthy but clean way to achieve it and also require an external library (pecl/http) to rebuild the URL which has been disassembled by parsing it.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s