php rtrim(), substr() delete the last character of a string_PHP tutorial

WBOY
Release: 2016-07-20 11:02:29
Original
1016 people have browsed it

There is a saying that we use these two functions to delete the last character of a string. rtrim deletes spaces and some special characters by default, but you can also delete specified characters. For substr, we take the character length. Naturally, as long as Just take the character length and subtract one, as shown in the following example.
*/

$str ='abcea';
echo rtrim($str,'a');


//Method 2

echo '
'.substr($str,0,strlen($str)-1);


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445366.htmlTechArticleWe use these two functions to delete the last character of the string. There is a saying that rtrim deletes spaces by default. and some special characters, but you can also delete specified characters, page substr i...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!