![]() ![]() We will use str_replace() to remove blank space from a string.Įcho $new_string Searching for presence of white space. We can search and inform the user about this or remove the blank space from the string variable. Introduction to the PHP rtrim() function To remove the whitespace characters or other characters from the end of a string, you use the PHP rtrim() function. We may not like to have blank space present within a string (example: userid entered by user in signup page ). Summary: in this tutorial, you’ll learn how to use the PHP rtrim() function to remove whitespace or other characters from the end of a string. Output is here Hello Wel Remove blank space present inside a string We removed the extra '+' at the end of the string, similarly we can remove extra, or any other chars from the end of the string. We can remove chars from the end of the string like this. $text= " This string has blank space at both sides " To remove extra blank space, line break, carriage return from both sides ( left and right ) of a string we can use trim() function Same way we can remove blank space from right side of any string by using rtrim() function. Remove blank space from left side of any string by using ltrim() function. Ltrim(), rtrim() and trim() Trimming the string
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |