Example: Removing whitespace using rtrim() function This function takes a string as its input value and returns a string having no extra whitespace to the right of the string. We can remove the whitespace from the right side of the string using the rtrim() function. Now we are going to learn how to remove the white space from the right side of the string. In the previous example, we have learned how to remove the whitespace from the left side of the string only. This is because the trim() function removes the whitespace from both sides while the ltrim() function removes only from the left of the string. String length of the output string is: 24Īs we can see in the output, the length of the output string is 24 while in the previous example length is 23. In the given example, we have removed the white space using ltrim() function. Example: Removing whitespace using ltrim() function We can remove the whitespace and special characters from the left of the string using the ltrim() function. But what if we want to remove the whitespace only from the left side of the string. The trim() function removes the white space from both sides (beginning and end) of the string. Previously we have discussed the trim() function. ![]() We can also remove the whitespace using the ltrim() function. String length of the output string is: 23 Using ltrim() function "" Įcho "String length of the output string is: ". Įcho "String length of input string is: ". ![]() In the given example, we have removed the whitespace from the given string using the trim() function. Example: Removing whitespace using trim() function ![]() The trim() function removes the white spaces, including non-breaking spaces, newlines, tabs, etc., from the beginning and end of the string. ![]() Along with the white space, this function removes the special characters present at the starting and end of the string. With this function You can compress Your PHP source code.We can remove the whitespace from the string using the trim() function. Getting Started Introduction A simple tutorial Language Reference Basic syntax Types Variables Constants Expressions Operators Control Structures Functions Classes and Objects Namespaces Enumerations Errors Exceptions Fibers Generators Attributes References Explained Predefined Variables Predefined Exceptions Predefined Interfaces and Classes Predefined Attributes Context options and parameters Supported Protocols and Wrappers Security Introduction General considerations Installed as CGI binary Installed as an Apache module Session Security Filesystem Security Database Security Error Reporting User Submitted Data Hiding PHP Keeping Current Features HTTP authentication with PHP Cookies Sessions Dealing with XForms Handling file uploads Using remote files Connection handling Persistent Database Connections Command line usage Garbage Collection DTrace Dynamic Tracing Function Reference Affecting PHP's Behaviour Audio Formats Manipulation Authentication Services Command Line Specific Extensions Compression and Archive Extensions Cryptography Extensions Database Extensions Date and Time Related Extensions File System Related Extensions Human Language and Character Encoding Support Image Processing and Generation Mail Related Extensions Mathematical Extensions Non-Text MIME Output Process Control Extensions Other Basic Extensions Other Services Search Engine Extensions Server Specific Extensions Session Extensions Text Processing Variable and Type Related Extensions Web Services Windows Only Extensions XML Manipulation GUI Extensions Keyboard Shortcuts ? This help j Next menu item k Previous menu item g p Previous man page g n Next man page G Scroll to bottom g g Scroll to top g h Goto homepage g s Goto search
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |