Alaa Gamal
Alaa Gamal

Reputation: 1135

strip out an part of an link

i've a pagination code in my project

but the problem is in the links

i get in links something like post?pid=2&page=2&page=3%page=6

I am trying to strip out the page

Here is an example

site.com/post.php?pid=12&page=10
site.com/category.php?cid=120&page=2

I am trying to get this results

site.com/post.php?pid=12
site.com/category.php?cid=120

Upvotes: 0

Views: 48

Answers (1)

Florian F.
Florian F.

Reputation: 4700

Best to do something like that would be to use regular expressions.

You could use preg_replace to replace whatever looks like &page=something by an empty string.

This should work :

$result = preg_replace("/&page=[0-9]*/i","",$initialurl);

Upvotes: 1

Related Questions