I am separating a string in array if there is a certain preposition in it ('with', 'to', 'by'), but I want to return the string containing the delimiter as well, ie the preposition. >
Using preg_split and explode, I have the same and unsatisfactory result:
$string = 'Programação com Stackoverflow';
$resultado = explode('com', $string);
$resultado2 = preg_split('/com|para|by|por/', $string);
Array
(
[0] => Programação
[1] => Stackoverflow
)
The expected result for what I'm looking for:
Array
(
[0] => Programação
[1] => com
[2] => Stackoverflow
)