Amy Neville Amy Neville - 8 months ago 64
PHP Question

Check if last character is a question mark

How do I check if the last character in a string is a question mark (?) using php?

This is my current attempt but it doesn't seem to work unfortunately:

if (substr(strrev(trim($link)),0,0) != "?")


if (substr(rtrim($link), -1) != "?") { 
  // Do stuff

Giving a negative start value to substr() makes it count from the end instead of the beginning.