I split first my string with explode.
$split= explode('Cars:', $string);
echo $split[0]; // first
echo $split[1]; // second
So but i want to keep the word "Cars:".
I try that.
preg_match_all('/\b(\w*Cars:\w*)\b/',
$string,
$split, PREG_SET_ORDER);
echo $split[0][0] . ", " . $split[0][1] . "\n";
echo $split[1][0] . ", " . $split[1][1] . "\n";
So what i need is i need to split a string in two parts. But i want to keep the delimiter.
My string is every time different, but here a example:
Price: $3,995
Mileage: 100,753 miles
Transmission: Manual
Exterior Color: Blue
Interior Color: Black
Engine: I4
Other Cars: Car 1, Car 2, Car 3
Other Cars: is a list of recommended cars. (Hyperlinks)
UPDATE: I got now that. But how can i use also : ? So Cars:
preg_split('/\b(\w*Cars\w*)\b/', $string, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);