$leftTrimmed = ltrim( $oldText );
PHP Coding tips & tricks. Function & error explanation, coding style, how tos etc. Short notes posted directly from developer work environment.
PHP Coding Tips
Showing posts with label spaces. Show all posts
Showing posts with label spaces. Show all posts
Monday, August 20, 2012
How to remove white space on the left of a strin ?
You can use ltrim() function to remove white symbols at begining of a string, as example shows:
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:
$trimmed = trim( $somestring );
echo "[".trim(" hello ")."]";
As you can see you can use this function inline to for example filter output.
Subscribe to:
Posts (Atom)