This post is about the different type of white space characters that you should expect when programming.

There are different ways of representing white space characters depending on a few factors.  However, here is a quick list of the variations:

  1. “\n” - used in NIX systems such as unix, linux.  This is a newline character.
  2. “\r\n” - used in windows for a newline character.
  3. “\t” - cross compatible tab character.
  4. “\x0B” - a vertical tab character.
  5. “\0″ - a null byte character.

If you want to remove those whitespace characters put the above characters into an array and do a simple str_replace() substitution like so:

<?php

$some_string = str_replace($whitespace_array, ”, $some_string);

?>

Discuss this article in the PHP Forum.