Function __global->cms_preg_split_safe

Definitions

sources/global3.php

  • Split string by a regular expression.Automatically applies utf-8 if possible and appropriate. \s is not actually Unicode-safe, for example (as it matches non-breaking-spaces).Also automatically applies the 'D' modifier so that trailing blank lines don't mess with '$'.
  • Visibility: public
  • Is abstract?: No
  • Is static?: No
  • Is final?: No
  • Returns: array

Parameters

Name Type Passed by reference? Variadic? Default Set Range Description
$pattern string No No required parameter N/A N/A The pattern
$subject string No No required parameter N/A N/A The subject
$max_splits integer No No -1 N/A N/A The maximum number of splits to make (-1: no limit)
$mode ?integer No No Null N/A N/A The special mode (null: none)

Returns

  • The array due to splitting
  • Type: array
  • Set: N/A
  • Range: N/A

Preview

Code (PHP)

/**
 * Split string by a regular expression.Automatically applies utf-8 if possible and appropriate. \s is not actually Unicode-safe, for example (as it matches non-breaking-spaces).Also automatically applies the 'D' modifier so that trailing blank lines don't mess with '$'.
 *
 * @param  string $pattern The pattern
 * @param  string $subject The subject
 * @param  integer $max_splits The maximum number of splits to make (-1: no limit)
 * @param  ?integer $mode The special mode (null: none)
 * @return array The array due to splitting
 */

function cms_preg_split_safe(string $pattern, string $subject, int $max_splits = -1, ?int $mode = null) : array