Skip to end of metadata
Go to start of metadata

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[

Zend Framework: Zend_Filter_StripSpaces Component Proposal

Proposed Component Name Zend_Filter_StripSpaces
Developer Notes
Proposers Thomas Weidner
Revision 1.0 - 04 Oktober 2009 (wiki revision: 11)

Table of Contents

1. Overview

Zend_Filter_StripSpaces will strip all spaces out of a string. You can specify if you want to strip out all spaces or just the unnecessary ones, means multiple spaces behind one another.

2. References

3. Component Requirements, Constraints, and Acceptance Criteria

  • This component will correctly strip out all repeated spaces, as they are insignificat in some context (e.g. html)
  • This component will correctly strip out all spaces, when specified
  • This component will also handle Unicode White Spaces
  • This component will not remove any other character

4. Dependencies on Other Framework Components

  • Zend_Filter_Interface
  • Zend_Filter_Exception

5. Theory of Operation

Based on the specified options, this filter will strip all, more than one and/or also unicode white spaces.

6. Milestones / Tasks

  • Milestone 1: [DONE] Proposal finished
  • Milestone 2: Proposal accepted
  • Milestone 3: Working implementation
  • Milestone 4: Unit tests
  • Milestone 5: Documentation
  • Milestone 6: Moved to core

7. Class Index

  • Zend_Filter_StripSpaces

8. Use Cases


Default, stripping multiple whitespaces (textual, unicode and html)


Stripping only multiple textual whitespaces


Stripping all whitespaces


Stripping multiple types of whitespaces


Stripping more than 3 whitespaces

9. Class Skeletons



Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Mar 03, 2008


    <p>this filter maybe should also strip tabs <ac:link><ri:page ri:content-title="\t" /></ac:link></p>


    <p>Martin H.</p>

  2. Apr 18, 2009

    <p>Karol, please tell me if you want to do any further progress with this proposal.<br />
    Otherwise I will take it over, change it to conform, get it approved and integrated.</p>

    <p>Greetings<br />
    Thomas Weidner</p>

  3. Jul 28, 2010

    <p>Why can't it filter out other characters on demand of the developer? If I want to filter out all occurrences of 'A' or 'a', this component should be able to. Imho. </p>

    1. Jul 30, 2010

      <p>This filter is intended to work only on spaces. You should note that unicode defines other whitespace characters which most people are not aware of.</p>

      <p>When you want to have a filter which strips out special characters then I would add a Zend_Filter_StripCharacters... Zend_Filter_StripSpaces would then be an extension of StripCharacters.</p>

      <p>I would do this based on this proposal when it's really wished.</p>

  4. Jul 29, 2010

    <p>If you have sentences and you used the default stripping what would the use case be for after a "."</p>


    <p>"This is a sentence. This is another sentence."</p>

    <p>Would it remove the double space after the sentence or leave that in?</p>

    1. Jul 30, 2010

      <p>In your example there is no double whitespace after the point.<br />
      But when there would be a multiple-whitespace it would be stripped.</p>

      <p>It would change TEXT-POINT-SPACE-SPACE-TEXT and return TEXT-POINT-SPACE-TEXT</p>

  5. Jul 30, 2010

    <p>For me it sounds like a html minimizer. This should be discussed with Nick Daugherty's Zend_Filter_Minify_Html.</p>

    1. Jul 30, 2010

      <p>No... this proposal is not intended to work on HTML or any other structured content.<br />
      It has no knowledge of any structure.</p>

      <p>Minify_Html would not work on a plain string text or on a textfile.</p>

  6. Aug 03, 2010

    <ac:macro ac:name="note"><ac:rich-text-body><p><strong>Community Review Team Recommendation</strong></p>

    <p>The CR Team advises that this proposal may be approved with the condition that the proposer clarify the precise range of characters that will be stripped.</p></ac:rich-text-body></ac:macro>

    1. Aug 03, 2010

      <p>As written and proposed this component can strip all sorts of spaces. This would include:</p>

      <li>Non-Breaking Space</li>
      <li>Space Mark</li>
      <li>Thick Space</li>
      <li>Mid Space</li>
      <li>Six-Em Space</li>
      <li>Figure Space</li>
      <li>Punctation Space</li>
      <li>Thin Space</li>
      <li>Hair Space</li>
      <li>Zero-Width Space</li>
      <li>Narrow Non-Breaking Space</li>
      <li>Medium Mathematical Space</li>
      <li>Word Joiner</li>
      <li>Ideographic Space</li>
      <li>Zero-Width Non-Breaking Space</li>

      <p>Each of them can be switched on/off separatly. This component would also recognise the HTML variant and strip it. This can also be switched off per option.</p>

      <p>Example:<br />
      Non-breaking Space = U+00A0 => HTML Variant = & nbsp;</p>

      <p>For each of the above spaces a HTML variant exists.</p>

  7. Aug 04, 2010

    <p>Thanks for the clarification Thomas!</p>