| Welcome to WebmasterWorld Guest from 22.214.171.124 |
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
|Become a Pro Member|
|exclude characters from counting?|
Hello, I wanted to ask if you have a string like:
is there a way to count the length of the string, excluding non-word characters (+,- or .)?
You could remove the chars you don't want with a str_replace [php.net] and then just get the length [php.net] of the string afterward.
Off the top of my head I can think of like 3 other ways to do this, but the one above seems simplest.
As eelixduppy said, just replace all the non-characters.
$chars = preg_replace("/\W/i","", $my_s);
echo $chars ."<br>";
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved