In PHP when you want to remove the blank spaces which are also called white spaces then you then you can use ltrim ( ) and rtrim ( ) function in. Below we take some example to explain these two function.
Suppose you have a form and in one text box you ask for enter the name. Some one enter the name but give some spaces before and after his/her name.
For example " Kiren Noreen ":
Above name contain two spaces before and two spaces after the name. When you store this name in your database with these spaces then this is very bad practices for programmer when some one want to search "Kiren Noreen" . its return zero record, because your name is store with spaces, So it is very necessary that you must remove these spaces before and after the string.
This function remove the spaces before the string.
This will return
"Kiren Noreen"
This function remove the spaces after the string.
This will return
"Kiren Noreen"
This function remove the All spaces before, after and between the string . For example if you have a name " Kiren Noreen ". This name contain two speces before the name and two after the name and one between the name. if you apply the trim function then it will give the output without spaces.
This will return
"KirenNoreen"
Variables in PHP
PHP Concatenation
Calculation in PHP
If Statements in PHP
if ... else Statements in PHP
Nested IF Structure in PHP
PHP Comparison Operators
Switch Statement in PHP
Logical Operators In PHP
PHP Booleans
FOR Loop in PHP
While Loop In PHP
foreach Loop In PHP
Break Statement
Array In PHP
Associative Array
The Count function
Changing Case Function
Trim Function In PHP
Str_shuffle( ) function
strpos function in PHP
Explode() Function in PHP
Function
Passing Function Arguments
Server Variables
Header Function
Include Function
The require Function