The difference between php trim function ltrim function rtrim function

巴扎黑
Release: 2016-11-12 14:17:23
Original
1525 people have browsed it

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 removes all spaces (actually, to be precise, it removes all spaces in the string twice), for example:
$str=" love 59biye ";
echo ("---". trim($str)."---");//Output---love 59biye---
2.php The ltrim() function removes the spaces on the left side of the string, for example:
$str=" love 59biye ";
echo ("---".ltrim($str)."---");//Output ---love 59biye ---
3.php The rtrim() function removes the right side of the string Space, for example:
$str=" love 59biye ";
echo ("---".ltrim($str)."---");//Output --- love 59biye---
Okay, Everyone can see their specific differences.

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