StringParser_BBCode class documentation
Author: Christian Seiler

# `StringParser_BBCode` class documentation

- Project homepage
- Documentation
- PHPDOC Documentation
- Download
- Diese Seite auf Deutsch

## 7. Limiting the amount of occurrences

### 7.1 Grouping codes

The class also provides the possibility to restrict the number of occurrences of a code. For this codes have to be organized in groups first and then it is possible to specify how often codes of a group my occur. The first code above the maximum number is simply ignored and appended as normal text. If one wants to restrict only one code one must nevertheless create a group. One assigns a code to a group with the help of the `setOccurrenceType` method:

`$bbcode->setOccurrenceType ('url', 'link');`

This would assign the `[url]` code to the `link` group. The name of the group is completely arbitrary. One has not to create the group before or something like this, one just has to specify it when calling the above method.

### 7.2 Setting limits

With the help of the method `setMaxOccurrences` one can specify how often elements of a group may occur. The method call looks like this:

`$bbcode->setMaxOccurrences ('link', 15);`

This would define for the `link` group a limit of 15 maximum occurrences. All further occurrences would be ignored.

- Next: 8. Paragraph handling
- Previous: 6. Flags to control the behaviour of the class