Home >Backend Development >PHP Tutorial >The difference between php trim function ltrim function rtrim function

The difference between php trim function ltrim function rtrim function

巴扎黑
巴扎黑Original
2017-06-09 13:59:502727browse

Everyone knows that PHP’s trim() function, ltrim() function, and rtrim() function can all remove spaces. So what are the differences in usage between the three? Now let me introduce them to you one by one.
1.php trim() function is to remove all spaces (in fact, to be precise, it is to remove all spaces in the string twice), for example:

$str=" love 59biye ";
echo ("---".trim($str)."---");//输出---love 59biye---

2.php ltrim() function is to remove the left side of the string Spaces, for example:

$str=" love 59biye ";
echo ("---".ltrim($str)."---");//输出---love 59biye ---

3.php The rtrim() function removes spaces on the right side of the string, for example:

$str=" love 59biye ";
echo ("---".ltrim($str)."---");//输出--- love 59biye---

Okay, everyone can see their specific differences.

Statement:
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
Previous article:cURL library under PHPNext article:cURL library under PHP