$trimmed = trim( $somestring );
echo "[".trim(" hello ")."]";
As you can see you can use this function inline to for example filter output.
PHP Coding tips & tricks. Function & error explanation, coding style, how tos etc. Short notes posted directly from developer work environment.
PHP Coding Tips
Monday, August 13, 2012
How to remove white space in PHP (remove spaces at begining and end of string)?
You can remove trailing and leading white characters in PHP. What is white character ? it's just a character wich we don't see like tab, space, or new line character. To remove white space characters in PHP just use trim() function. It will do the work, here comes two sample codes:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment