Let’s say my URL is this:
http://example.com/forum/index.php?topic=53.msg251#msg251
This part here, I can’t figure out how to remove:
.msg251#msg251
I did try though, I’m not sure if I am even close to doing it right.
$linkraw = $items->link;
$linkpattern = '/^.msg247#msg247/';
$link = preg_match($linkpattern, $linkraw);
What is the correct way of doing this? I am trying to learn.
String functions strrpos and substr are enough for this task. And its surely faster.
Explanation:
strrposfinds the position of.from the end of the string.substrextracts a sub string till the position of.found in previous step.When this will work?
Works on
http://example.com/forum/index.php?topic=53.msg251#msg251Works on
http://example.com/forum/index.php?topic=53.new#newBut not on
http://example.com/forum/index.php?topic=53.msg251#msg251.new#new