There are many questions like this question but I can not find exact answer. And I am unfamiliar Regular Expresion topic.
I wanted to know if $variable
ends with "books".
For example :
$variable = "some-historical-books".
So, I will display books page if it ends with books.
Thank you.
Maybe you should look into a tutorial. What you are looking for is an anchor, that marks the end of the string.
if(preg_match('/books$/', $variable))
// redirect to books page
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