String Trim

From KlavoWiki
Revision as of 04:30, 16 July 2009 by David (Sọ̀rọ̀ | contribs) (Created page with 'To strip all spaces, tabs and new lines from a string using PHP. The paramater $i is the string that will be stripped of the spaces, tabs or new lines. <pre> $sPattern = "/\s*/m"...')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

To strip all spaces, tabs and new lines from a string using PHP. The paramater $i is the string that will be stripped of the spaces, tabs or new lines.

$sPattern = "/\s*/m";
$sReplace = "";

preg_replace( $sPattern, $sReplace, $i );