> I would like to replace all chars in a string that are not a-z or 0-9
> with a space. I can use a series of str_replace functions, but there
> has to be a faster way.
Use one ereg_replace function.
Where $string is the string you mention....
ereg_replace("[^a-z0-9]", " ", $string)
This will replace all characters that are not a-z or 0-9 (including
spaces!) with a space.
Notice, this will also replace any uppercase letters (A-Z) with a space.
If you want uppercase letters to be left alone, use the following:
ereg_replace("[^A-Za-z0-9]", " ", $string)
Rationale: The [] square brackets indicate a set of possible matches to be
searched for. The ^ carat at the beginning indicates "not any of these".
Michael Roush
[EMAIL PROTECTED]
"The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect."
-- Tim Berners-Lee, W3C Director and inventor of the World Wide Web
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
The php_mysql group is dedicated to learn more about the PHP/MySQL web database possibilities through group learning.
SPONSORED LINKS
| American general life and accident insurance company | American general life insurance company | American general life |
| American general mortgage | American general life insurance | Computer internet security |
YAHOO! GROUPS LINKS
- Visit your group "php_mysql" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
