the charmask is a list of characters that get deleted if they are at the left or right of a string (depending on which of trim, ltrim and rtrim you use).
so
Code:
echo rtrim ("123.00", "0.");
will give you
Code:
123
but
Code:
rtrim ("123.00.....", "0.");
will also yield the same result.
if you are looking to format numbers, use printf (or its variants) or number_format
i tend to use the trim functions for cleaning user input and for getting rid of trailing commas in assembled sql clauses.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.