Home > Backend Development > PHP Tutorial > Summary of common methods for removing hollow characters in strings in PHP, summary of hollow characters in PHP strings_PHP tutorial

Summary of common methods for removing hollow characters in strings in PHP, summary of hollow characters in PHP strings_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:02:44
Original
891 people have browsed it

A summary of common methods for removing hollow characters in strings in PHP, a summary of hollow characters in PHP strings

The examples in this article summarize the common methods of removing hollow characters in strings in PHP. Share it with everyone for your reference. The specific analysis is as follows:

php contains four functions that can remove spaces from strings:

trim() – removes null characters from both ends of a string
ltrim() – removes null characters at the front of a string
rtrim() – removes null characters at the end of a string
chop() – same as rtrim().

The code is as follows:

<&#63;php
$text = "\t \t jb51.net!\t \t ";
$leftTrimmed = ltrim($text);
$rightTrimmed = rtrim($text);
$bothTrimmed = trim($text);
print("leftTrimmed = ($leftTrimmed)\n");
print("rightTrimmed = ($rightTrimmed)\n");
print("bothTrimmed = ($bothTrimmed)\n");
&#63;>
Copy after login

Output result:

leftTrimmed = (jb51.net! )
rightTrimmed = ( jb51.net!)
bothTrimmed = (jb51.net!)
Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/969499.htmlTechArticleSummary of common methods for removing hollow characters in strings in PHP, summary of hollow characters in PHP strings This article summarizes the removal of strings in PHP with examples Common method for hollow characters. Share it with everyone for your reference. Tool...
Related labels:
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template