You are here

public static function NameUnicodeExtras::explode in Name Field 8

Split each word in a UTF-8 string.

Parameters

string $text: The text that will be converted.

Return value

array The input $text as an array of words.

2 calls to NameUnicodeExtras::explode()
NameUnicodeExtras::initials in src/NameUnicodeExtras.php
Generate the initials of all first characters in a string.
NameUnicodeExtrasTest::testNameUnicodeExtras in tests/src/Unit/NameUnicodeExtrasTest.php
Test NameUnicodeExtras functions.

File

src/NameUnicodeExtras.php, line 23

Class

NameUnicodeExtras
Provides custom Unicode-related extension methods.

Namespace

Drupal\name

Code

public static function explode($text) {
  $regex = '/(^|[' . static::PREG_CLASS_WORD_BOUNDARY . '])/u';
  $words = preg_split($regex, $text, NULL, PREG_SPLIT_NO_EMPTY);
  return $words;
}