trim() function will truncate spaces or other characters from the beginning and end of input string. It will remove “hi” from starting and “es.” from the end of input string “hi from tutorialmines.”.
The following characters are removed if the charlist parameter is empty:
This will return a trimmed string.
<?php // below statement will trim white spaces from both sides of string." $strExample = " Hi from tutorialmines. "; echo trim($strExample); ?>
In above example ,We have a string ” Hi from tutorialmines. “. Now this function will trim blank spaces from both side of string. Output of above code in the browser is as below:
<?php // below statement will trim white spaces from both sides of string." $strExample = " \nHi from \ntutorialmines.\n\n "; echo trim($strExample); ?>
In above example ,We have a string ‘ \nHi from \ntutorialmines.\n\n ‘. Now this function will trim blank spaces,\n character from both side of string. Output in ViewSource of browser is below ( HTML output of the code above):
<html><head></head><body> Hi from tutorialmines. </body></html>
See below is the output of above code.
<?php $strExample = "Hi from tutorialmines. This is a example of trim() function. Testing parameter"; echo trim($strExample,"Hi..parameter"); ?>
In above example ,We have a string ‘Test Hi from tutorialmines. This is a example of trim() function. Testing parameter’. Now this function remove “Test ” from the starting and “parameter” from the end of string. See below is the output of above code.
from tutorialmines. This is a example of trim() function. Testing
App usage is growing steadily without showing any signs of slowing down. Hence, it is no surprise that mobile applications…
As the world has grown more digital, businesses have adapted themselves. An effectual adaptation includes online advertising. Offline advertising styles…
Step into a world where apps dance to the user's tune. Picture Instagram, a photo-sharing sensation that swept the globe.…
COVID-19 has led to a digitalization of lifestyle. As patients are taking their mental and physical health more seriously, healthcare…
Introduction WordPress, an immensely popular content management system (CMS), powers over 40% of the internet. What makes WordPress even more…
For moving companies trying to capture their market share amidst stiff competition, a tip or two about what they can…