code: private static function extractFragments($text, $delimiters)
      {
          // special case: split into characters
          if (empty($delimiters)) {
              $chars = str_split($text, 1);
              $chars[strlen($text)] = '';
              return $chars;
          }
          $fragments = array();
          $start = $end = 0;
          for (; ;) {
              $end += strcspn($text, $delimiters, $end);
              $end += strspn($text, $delimiters, $end);
              if ($end === $start) {
                  break;
              }
              $fragments[$start] = substr($text, $start, $end - $start);
              $start = $end;
          }
          $fragments[$start] = '';
          return $fragments;
      }
docs: Efficiently fragment the text into an array according to
  specified delimiters.
  No delimiters means fragment into single character.
  The array indices are the offset of the fragments into
  the input string.
  A sentinel empty fragment is always added at the end.
  Careful: No check is performed as to the validity of the
  delimiters.