I'm using the following code to split my UTF-8 strings to characters:
$characters = preg_split('//u', $word, -1, PREG_SPLIT_NO_EMPTY);
In some cases, a character might have a single quote after it. for example: hel'lo
. I want to keep that quote with the character before it.
Using the regex above, my array is this:
Array
(
[0] => h
[1] => e
[2] => l
[3] => '
[4] => l
[5] => o
)
And I want the array to be:
Array
(
[0] => h
[1] => e
[2] => l'
[3] => l
[4] => o
)
How can I do it? Thanks!
(the single quote can be at the beginning of the string, at the end of it and in the middle of it).