Problem: Some of the post names on my WordPress site are questions, i.e. The message header ends with a question mark. And I have mail requests that generate lists of recent messages. Therefore, I am trying to calculate a little php that will keep punctuation correct.
What is a good way to determine if the last title character is a question mark and not repeat the period? And if the message header is not a question, repeat the period.
This is what I am trying to use to get the title in the wordpress request and then determine if the title is a question, but it does not print a period.
There must be something simple, I'm wrong here:
<?php $mytitle = get_the_title(); echo $mytitle; ?>
<?php $question = substr($mytitle, -1); if (!$question = '?'): echo '.'; endif; ?>
Edit 3/03/10
Now it works:
<?php $mytitle = get_the_title(); echo $mytitle; ?>
<?php $question = substr($mytitle, -1); if ($question != '?') { echo '.'; } ?>