I have:
http://stackoverflow.com/questions/43242&cat=aa&id=342342
http://stackoverflow.com/questions/43242&cat=aa&body=434&id=232
http://stackoverflow.com/questions/43242&cat=aa&call=2323&id=14143434
i would like receive:
this link without parameter id:
http://stackoverflow.com/questions/43242&cat=aa
http://stackoverflow.com/questions/43242&cat=aa&body=434
http://stackoverflow.com/questions/43242&cat=aa&call=2323
how this make with PHP? str_replace + regular expression?
preg_replace('~&id=[0-9]+~', '', $str);
Use the appropriate function for this, not regular expressions since URL's aren't regular.
You should then split the query part, which can be done with regular expressions, but I'd like to split on & and then filter out the ID part.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With