PHP rtrim “.php”

后端 未结 3 2043
情歌与酒
情歌与酒 2021-01-14 00:02

I want to remove \".php\" from the end of a string if it exists. Consider this:

$filename = \'index\';
rtrim($filename,\".php\");//returns \"index\"

$filena         


        
3条回答
  •  迷失自我
    2021-01-14 00:20

    if you're simply trying to remove the extension, why not use this: $filename = 'index.php'; $name = strstr($filename, '.', true);

提交回复
热议问题