doukanwa6872 2013-05-01 21:58
浏览 86
已采纳

在PHP中使用字符串末尾的问号

I'm new to php, but wasn't able to find a straight answer online, so decided to ask Stack Overflow.

I have a variable, and I want to make a statement similar to the following:

if ($var has a question mark at end)
{
$var = ($var - question mark)
}

Thanks in advance!

--EDIT--

I ended up using the following:

if (substr($var, -1) == "?")
{
$var = rtrim($input, "?");
}

Thanks again for the quick feedback. God I love this site.

--END EDIT--

  • 写回答

5条回答 默认 最新

  • dt56449492 2013-05-01 22:08
    关注

    Simple answer:

    $var = rtrim($var, '?');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?