Home

Geeklog: What I Learnt Today / Adam

Stripping white space from file but preserving in code tags

> Stripping white space from file but preserving in code tags.
Another thing i found difficult but this seems to work for now

/* strip out excess where not in code tags*/
/* all the white space with single space */
$data = preg_replace('/(?!(?:[^|[^>]+))(\s)/i'," ",
trim($data));
   /* all the double spaces */
$data = preg_replace("/(?!(?:[^|[^>]+))( ){2,}/"," ",$data);
/* all the > < spaces with >< */ $data = preg_replace("/(?!(?:[^|[^>]+))(>

/ Adam