2

Tell me, please, how to split a string character by character into an array, but so that the stresses (for example, one) in the array do not lie as a separate character, but remain with a letter?

Now it works like this, but stresses are considered a separate character.

$ arrayLetters = preg_split ('// u', $ string, NULL, PREG_SPLIT_NO_EMPTY);

1 Answers1

0

Hope is's help:

$str = 'PHP';
$chars = preg_split('//', $str, -1, PREG_SPLIT_NO_EMPTY);
print_r($chars);

Output:

Array
(
    [0] => P
    [1] => H
    [2] => P
)
Dmitry Leiko
  • 3,970
  • 3
  • 25
  • 42