Word Filters

In addition to the standard set of filters, there are several classes specific to filtering word strings.

CamelCaseToDash

This filter modifies a given string such that ‘CamelCaseWords’ are converted to ‘camel-case-words’.

Supported Options

There are no additional options for Zend\Filter\Word\CamelCaseToDash:

Basic Usage

A basic example of usage is below:

1
2
3
$filter = new Zend\Filter\Word\CamelCaseToDash();

print $filter->filter('ThisIsMyContent');

The above example returns ‘this-is-my-content’.

CamelCaseToSeparator

This filter modifies a given string such that ‘CamelCaseWords’ are converted to ‘camel case words’.

Supported Options

The following options are supported for Zend\Filter\Word\CamelCaseToSeparator:

  • separator: A separator char. If this is not set the separator will be a space character.

Basic Usage

A basic example of usage is below:

1
2
3
4
$filter = new Zend\Filter\Word\CamelCaseToSeparator(':');
// or new Zend\Filter\Word\CamelCaseToSeparator(array('separator' => ':'));

print $filter->filter('ThisIsMyContent');

The above example returns ‘this:is:my:content’.

Default Behavior

1
2
3
$filter = new Zend\Filter\Word\CamelCaseToSeparator();

print $filter->filter('ThisIsMyContent');

The above example returns ‘this is my content’.

CamelCaseToUnderscore

This filter modifies a given string such that ‘CamelCaseWords’ are converted to ‘camel_case_words’.

Supported Options

There are no additional options for Zend\Filter\Word\CamelCaseToUnderscore:

Basic usage

A basic example of usage is below:

1
2
3
$filter = new Zend\Filter\Word\CamelCaseToUnderscore();

print $filter->filter('ThisIsMyContent');

The above example returns ‘this_is_my_content’.

DashToCamelCase

This filter modifies a given string such that ‘words-with-dashes’ are converted to ‘WordsWithDashes’.

Supported Options

There are no additional options for Zend\Filter\Word\DashToCamelCase:

Basic Usage

A basic example of usage is below:

1
2
3
$filter = new Zend\Filter\Word\DashToCamelCase();

print $filter->filter('this-is-my-content');

The above example returns ‘ThisIsMyContent’.

DashToSeparator

This filter modifies a given string such that ‘words-with-dashes’ are converted to ‘words with dashes’.

Supported Options

The following options are supported for Zend\Filter\Word\DashToSeparator:

  • separator: A separator char. If this is not set the separator will be a space character.

Basic Usage

A basic example of usage is below:

1
2
3
4
$filter = new Zend\Filter\Word\DashToSeparator('+');
// or new Zend\Filter\Word\CamelCaseToSeparator(array('separator' => '+'));

print $filter->filter('this-is-my-content');

The above example returns ‘this+is+my+content’.

Default Behavior

1
2
3
$filter = new Zend\Filter\Word\DashToSeparator();

print $filter->filter('this-is-my-content');

The above example returns ‘this is my content’.

DashToUnderscore

This filter modifies a given string such that ‘words-with-dashes’ are converted to ‘words_with_dashes’.

Supported Options

There are no additional options for Zend\Filter\Word\DashToUnderscore:

Basic Usage

A basic example of usage is below:

1
2
3
$filter = new Zend\Filter\Word\DashToUnderscore();

print $filter->filter('this-is-my-content');

The above example returns ‘this_is_my_content’.

SeparatorToCamelCase

This filter modifies a given string such that ‘words with separators’ are converted to ‘WordsWithSeparators’.

Supported Options

The following options are supported for Zend\Filter\Word\SeparatorToCamelCase:

  • separator: A separator char. If this is not set the separator will be a space character.

Basic Usage

A basic example of usage is below:

1
2
3
4
$filter = new Zend\Filter\Word\SeparatorToCamelCase(':');
// or new Zend\Filter\Word\SeparatorToCamelCase(array('separator' => ':'));

print $filter->filter('this:is:my:content');

The above example returns ‘ThisIsMyContent’.

Default Behavior

1
2
3
$filter = new Zend\Filter\Word\SeparatorToCamelCase();

print $filter->filter('this is my content');

The above example returns ‘ThisIsMyContent’.

SeparatorToDash

This filter modifies a given string such that ‘words with separators’ are converted to ‘words-with-separators’.

Supported Options

The following options are supported for Zend\Filter\Word\SeparatorToDash:

  • separator: A separator char. If this is not set the separator will be a space character.

Basic Usage

A basic example of usage is below:

1
2
3
4
$filter = new Zend\Filter\Word\SeparatorToDash(':');
// or new Zend\Filter\Word\SeparatorToDash(array('separator' => ':'));

print $filter->filter('this:is:my:content');

The above example returns ‘this-is-my-content’.

Default Behavior

1
2
3
$filter = new Zend\Filter\Word\SeparatorToDash();

print $filter->filter('this is my content');

The above example returns ‘this-is-my-content’.

SeparatorToSeparator

This filter modifies a given string such that ‘words with separators’ are converted to ‘words-with-separators’.

Supported Options

The following options are supported for Zend\Filter\Word\SeparatorToSeparator:

  • searchSeparator: The search separator char. If this is not set the separator will be a space character.
  • replaceSeparator: The replace separator char. If this is not set the separator will be a dash.

Basic Usage

A basic example of usage is below:

1
2
3
$filter = new Zend\Filter\Word\SeparatorToSeparator(':', '+');

print $filter->filter('this:is:my:content');

The above example returns ‘this+is+my+content’.

Default Behaviour

1
2
3
$filter = new Zend\Filter\Word\SeparatorToSeparator();

print $filter->filter('this is my content');

The above example returns ‘this-is-my-content’.

UnderscoreToCamelCase

This filter modifies a given string such that ‘words_with_underscores’ are converted to ‘WordsWithUnderscores’.

Supported Options

There are no additional options for Zend\Filter\Word\UnderscoreToCamelCase:

Basic Usage

A basic example of usage is below:

1
2
3
$filter = new Zend\Filter\Word\UnderscoreToCamelCase();

print $filter->filter('this_is_my_content');

The above example returns ‘ThisIsMyContent’.

UnderscoreToSeparator

This filter modifies a given string such that ‘words_with_underscorees’ are converted to ‘words with underscorees’.

Supported Options

The following options are supported for Zend\Filter\Word\UnderscoreToSeparator:

  • separator: A separator char. If this is not set the separator will be a space character.

Basic usage

A basic example of usage is below:

1
2
3
4
$filter = new Zend\Filter\Word\UnderscoreToSeparator('+');
// or new Zend\Filter\Word\CamelCaseToSeparator(array('separator' => '+'));

print $filter->filter('this_is_my_content');

The above example returns ‘this+is+my+content’.

Default Behavior

1
2
3
$filter = new Zend\Filter\Word\UnderscoreToSeparator();

print $filter->filter('this_is_my_content');

The above example returns ‘this is my content’.

UnderscoreToDash

This filter modifies a given string such that ‘words_with_underscores’ are converted to ‘words-with-underscores’.

Supported Options

There are no additional options for Zend\Filter\Word\UnderscoreToDash:

Basic usage

A basic example of usage is below:

1
2
3
$filter = new Zend\Filter\Word\UnderscoreToDash();

print $filter->filter('this_is_my_content');

The above example returns ‘this-is-my-content’.

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 Word Filters 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.