Remove Whitespace from user input

I have a form which takes a name of a person. I have created a variable to contain the post array value.

$name = $_POST["name"];

I have also created a variable to contain the number of characters that is contained in the name.

$len = strlen($name);

when a user enters there full name the strlen function counts the white space is there a function that I can use that would only count the characters entered by the user?

For example my program would output "abc d" as 5 characters and not 4.
[536 byte] By [RajaCode] at [2007-11-20 8:36:46]
# 1 Re: Remove Whitespace from user input
$len = strlen(preg_replace('/\s/', '', $name));
reko_t at 2007-11-10 3:56:17 >
# 2 Re: Remove Whitespace from user input
Or for faster results...
$characters= strlen(str_replace(' ', '', $name));
PeejAvery at 2007-11-10 3:57:27 >
# 3 Re: Remove Whitespace from user input
Or for faster results...
$characters= strlen(str_replace(' ', '', $name));

Thanks it worked. Why is this faster then the previous poster's suggestion?
RajaCode at 2007-11-10 3:58:25 >
# 4 Re: Remove Whitespace from user input
Regular expressions use extra processing because it has to weed through the data with the given parameters. Now, say you wanted to check/change multiple (3 or more) items. In that case, preg_replace() would be faster. Read more about it here ( http://www.php-scripts.com/php_diary/011303.php3).
PeejAvery at 2007-11-10 3:59:20 >