PHP rtrim() 函数

 

code

<!DOCTYPE html>
<html>
<body>

<?php
$str = "Hello World!";
echo $str . "<br>";
echo rtrim($str,"World!");
?>
  
</body>
</html>

输出

Hello World!
Hello

 

参考:

https://www.w3school.com.cn/php/func_string_rtrim.asp