I want to split a string in to array. I want that the words and the metacharacters separated in an array. Like this:
$string = 'This is a string? Or an array?';
i want:
array[0] = 'This',
array[1] = 'is',
array[2] = 'a',
array[3] = 'string',
array[4] = '?',
array[5] = 'Or',
array[6] = 'etc';
I know that must use preg_split
. But i can manage only selecting strings or no string. And i searched for on the internet but i only could found examples without the metacharacters.
I hope that some one know the answer, because i its in the delimiter of the preg_spilt
.
Thank you for your time.