Home > Backend Development > PHP Tutorial > php trim函数 ltrim函数 rtrim函数的差异

php trim函数 ltrim函数 rtrim函数的差异

WBOY
Release: 2016-06-13 11:52:38
Original
1286 people have browsed it

php trim函数 ltrim函数 rtrim函数的区别

大家都知道php的trim()函数,ltrim()函数,rtrim()函数都可以去除掉空格,那么三者在用法上有什么不同的区别那?现在就来为大家一一介绍一下。
1.php trim()函数是去掉所有的空格(其实准确的来说是去掉字符串两次的所有空格),例如:
$str=" love 59biye ";<br>echo ("---".trim($str)."---");//输出---love 59biye---<br>2.php ltrim()函数是去掉字符串左侧的空格,例如:
$str=" love 59biye ";<br>echo ("---".ltrim($str)."---");//输出---love 59biye ---<br>3.php rtrim()函数是去掉字符串右侧的空格,例如:
$str=" love 59biye ";<br>echo ("---".ltrim($str)."---");//输出--- love 59biye---<br>好了,大家看出他们的具体的区别了吧。

Related labels:
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