strip spaces from string using smarty
18,799
Solution 1
From the documentation:
{$YourVariable|replace:' ':''}
Solution 2
anything between strip, all spaces will be removed.
{strip}{/strip}
Comments
-
vandu almost 2 years
I am new to smarty.
I want to know how to remove all white-space characters from a given string in Smarty?
I have a string like "this is my string". The output should be "thisismystring".
How can I do this?
-
Lucas over 11 yearsAs far as I'm concerned, that only removes trailing spaces.
-
mishmash over 11 yearsThis will not do what he wants: smarty.net/docs/en/language.modifier.strip.tpl
-
amitchhajer over 11 yearsthey have rtrim and ltrim in smarty phk.tekwire.net/demo/Smarty_xref.php5/nav.html?_functions/…
-
mishmash over 11 yearsI don't see a reference to rtrim/ltrim in the official Smarty docs. But if they behave like trim functions usually do (remove whitespace or other chars from beginning or end) it still would not do what he wants. :P
-
amitchhajer over 11 years@vanneto he wants to remove trailing spaces only
-
mishmash over 11 yearsI quote: "I have a string like "this is my string". The output should be "thisismystring"." That string doesn't even have trailing spaces. Next time, read the question please.
-
amitchhajer over 11 yearsthe first comment made me confuse, i thought he is the questionnaire and he's is concerned about removing trailing spaces now! my bad