Since: 5.5

class IntlBreakIterator implements IteratorAggregate (View source)

A “break iterator” is an ICU object that exposes methods for locating boundaries in text (e.g. word or sentence boundaries). The PHP IntlBreakIterator serves as the base class for all types of ICU break iterators. Where extra functionality is available, the intl extension may expose the ICU break iterator with suitable subclasses, such as IntlRuleBasedBreakIterator or IntlCodePointBreakIterator.

This class implements IteratorAggregate. Traversing an IntlBreakIterator yields non-negative integer values representing the successive locations of the text boundaries, expressed as UTF-8 code units (byte) counts, taken from the beginning of the text (which has the location 0). The keys yielded by the iterator simply form the sequence of natural numbers {0, 1, 2, …}.

Constants

DONE

WORD_NONE

WORD_NONE_LIMIT

WORD_NUMBER

WORD_NUMBER_LIMIT

WORD_LETTER

WORD_LETTER_LIMIT

WORD_KANA

WORD_KANA_LIMIT

WORD_IDEO

WORD_IDEO_LIMIT

LINE_SOFT

LINE_SOFT_LIMIT

LINE_HARD

LINE_HARD_LIMIT

SENTENCE_TERM

SENTENCE_TERM_LIMIT

SENTENCE_SEP

SENTENCE_SEP_LIMIT

Methods

static IntlBreakIterator|null
createCharacterInstance(string $locale = null)

(PHP 5 >=5.5.0)
Create break iterator for boundaries of combining character sequences

createCodePointInstance()

(PHP 5 >=5.5.0)
Create break iterator for boundaries of code points

static IntlBreakIterator|null
createLineInstance(string $locale = null)

(PHP 5 >=5.5.0)
Create break iterator for logically possible line breaks

static IntlBreakIterator|null
createSentenceInstance(string $locale = null)

(PHP 5 >=5.5.0)
Create break iterator for sentence breaks

static IntlBreakIterator|null
createTitleInstance(string $locale = null)

(PHP 5 >=5.5.0)
Create break iterator for title-casing breaks

static IntlBreakIterator|null
createWordInstance(string $locale = null)

(PHP 5 >=5.5.0)
Create break iterator for word breaks

int
current()

(PHP 5 >=5.5.0)
Get index of current position

int
first()

(PHP 5 >=5.5.0)
Set position to the first character in the text

int
following(int $offset)

(PHP 5 >=5.5.0)
Advance the iterator to the first boundary following specified offset

int
getErrorCode()

(PHP 5 >=5.5.0)
Get last error code on the object

string
getErrorMessage()

(PHP 5 >=5.5.0)
Get last error message on the object

string|false
getLocale(int $type)

(PHP 5 >=5.5.0)
Get the locale associated with the object

getPartsIterator(int|string $type = IntlPartsIterator::KEY_SEQUENTIAL)

(PHP 5 >=5.5.0)
Create iterator for navigating fragments between boundaries

string|null
getText()

(PHP 5 >=5.5.0)
Get the text being scanned

bool
isBoundary(int $offset)

(PHP 5 >=5.5.0)
Tell whether an offset is a boundary's offset

int
last()

(PHP 5 >=5.5.0)
Set the iterator position to index beyond the last character

int
next(int $offset = null)

(PHP 5 >=5.5.0)

int
preceding(int $offset)

(PHP 5 >=5.5.0)

int
previous()

(PHP 5 >=5.5.0)
Set the iterator position to the boundary immediately before the current

setText(string $text)

(PHP 5 >=5.5.0)
Set the text being scanned

getIterator()

No description

Details

static IntlBreakIterator|null createCharacterInstance(string $locale = null)

(PHP 5 >=5.5.0)
Create break iterator for boundaries of combining character sequences

Parameters

string $locale

Return Value

IntlBreakIterator|null

static IntlCodePointBreakIterator createCodePointInstance()

(PHP 5 >=5.5.0)
Create break iterator for boundaries of code points

static IntlBreakIterator|null createLineInstance(string $locale = null)

(PHP 5 >=5.5.0)
Create break iterator for logically possible line breaks

Parameters

string $locale [optional]

Return Value

IntlBreakIterator|null

static IntlBreakIterator|null createSentenceInstance(string $locale = null)

(PHP 5 >=5.5.0)
Create break iterator for sentence breaks

Parameters

string $locale [optional]

Return Value

IntlBreakIterator|null

static IntlBreakIterator|null createTitleInstance(string $locale = null)

(PHP 5 >=5.5.0)
Create break iterator for title-casing breaks

Parameters

string $locale [optional]

Return Value

IntlBreakIterator|null

static IntlBreakIterator|null createWordInstance(string $locale = null)

(PHP 5 >=5.5.0)
Create break iterator for word breaks

Parameters

string $locale [optional]

Return Value

IntlBreakIterator|null

int current()

(PHP 5 >=5.5.0)
Get index of current position

Return Value

int

int first()

(PHP 5 >=5.5.0)
Set position to the first character in the text

Return Value

int

int following(int $offset)

(PHP 5 >=5.5.0)
Advance the iterator to the first boundary following specified offset

Parameters

int $offset

Return Value

int

int getErrorCode()

(PHP 5 >=5.5.0)
Get last error code on the object

Return Value

int

string getErrorMessage()

(PHP 5 >=5.5.0)
Get last error message on the object

Return Value

string

string|false getLocale(int $type)

(PHP 5 >=5.5.0)
Get the locale associated with the object

Parameters

int $type

Return Value

string|false

IntlPartsIterator getPartsIterator(int|string $type = IntlPartsIterator::KEY_SEQUENTIAL)

(PHP 5 >=5.5.0)
Create iterator for navigating fragments between boundaries

Parameters

int|string $type

[optional]

Optional key type. Possible values are:

  • {[IntlPartsIterator](https://www.php.net/IntlPartsIterator) The default. Sequentially increasing integers used as key.
  • {[IntlPartsIterator](https://www.php.net/IntlPartsIterator) Byte offset left of current part used as key.
  • {[IntlPartsIterator](https://www.php.net/IntlPartsIterator) Byte offset right of current part used as key.

Return Value

IntlPartsIterator

string|null getText()

(PHP 5 >=5.5.0)
Get the text being scanned

Return Value

string|null

bool isBoundary(int $offset)

(PHP 5 >=5.5.0)
Tell whether an offset is a boundary's offset

Parameters

int $offset

Return Value

bool

int last()

(PHP 5 >=5.5.0)
Set the iterator position to index beyond the last character

Return Value

int

int next(int $offset = null)

(PHP 5 >=5.5.0)

Parameters

int $offset [optional]

Return Value

int

int preceding(int $offset)

(PHP 5 >=5.5.0)

Parameters

int $offset

Return Value

int

int previous()

(PHP 5 >=5.5.0)
Set the iterator position to the boundary immediately before the current

Return Value

int

setText(string $text)

(PHP 5 >=5.5.0)
Set the text being scanned

Parameters

string $text

Traversable getIterator()

Since: 8.0

No description

Return Value

Traversable

An instance of an object implementing Iterator or Traversable