Zend_Filter_Alpha is a filter which returns the string
$value, removing all but alphabetic characters. This filter includes an
option to also allow white space characters.
The following options are supported for Zend_Filter_Alpha:
allowwhitespace: If this option is set then whitespace characters are allowed. Otherwise they are suppressed. By default whitespace characters are not allowed.
A basic example of usage is below:
<?php
$filter = new Zend_Filter_Alpha();
print $filter->filter('This is (my) content: 123');
The above example returns 'Thisismycontent'. Notice that the whitespace characters and brackets are removed.
Note
Zend_Filter_Alpha works on most languages; however, there
are three exceptions: Chinese, Japanese and Korean. With these languages the
english alphabet is used. The language is detected through the use of
Zend_Locale.
Zend_Filter_Alpha can also allow whitespace characters. This can
be useful when you want to strip special characters from a string. See the following
example:
<?php
$filter = new Zend_Filter_Alpha(array('allowwhitespace' => true));
print $filter->filter('This is (my) content: 123');
The above example returns 'This is my content '. Notice that the parenthesis, colon, and numbers have all been removed while the whitespace characters remain.
To change allowWhiteSpace after instantiation the method
setAllowWhiteSpace() may be used.
To query the current value of allowWhiteSpace the method
getAllowWhiteSpace() may be used.




