3
I am separating a string in array if there is a certain preposition in it ('com', 'for', 'por'), but I want the return of this string also containing the delimiter, ie the preposition.
Using the preg_split and explodes, I have the same result and unsatisfactory:
$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 seek:
Array
(
[0] => Programação
[1] => com
[2] => Stackoverflow
)
You want when it contains
com
, "burst" the string? You wouldn’t have to check the word firstcom|para|by|por
withpreg_match
?– Wallace Maxters
Yes, @Wallacemaxters. And I need the preposition next to the result.
– Marcelo de Andrade