Alpha

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.

Supported options for Zend_Filter_Alpha

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.

Basic usage

A basic example of usage is below:

1
2
3
$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 Locale.

Allow whitespace characters

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:

1
2
3
$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.

Project Versions

Table Of Contents

This Page

Note: You need to stay logged into your GitHub account to contribute to the documentation.

Edit this document

Edit this document

The source code of this file is hosted on GitHub. Everyone can update and fix errors in this document with few clicks - no downloads needed.

  1. Login with your GitHub account.
  2. Go to Alpha on GitHub.
  3. Edit file contents using GitHub's text editor in your web browser
  4. Fill in the Commit message text box at the end of the page telling why you did the changes. Press Propose file change button next to it when done.
  5. On Send a pull request page you don't need to fill in text anymore. Just press Send pull request button.
  6. Your changes are now queued for review under project's Pull requests tab on GitHub.