Consider the following string:
I have had the greatest {A} {B} day yesterday {C}
I want to create an array with bi-grams, ignoring all labels (labels are between {brackets})
[0] => I-have
[1] => have-had
[2] => had-the
[3] => the-greatest
[4] => greatest-day
[5] => day-yesterday
In PHP, what is the best way to do this? Using regex or exploding on ” ” and then iterating through all the words? I’m having trouble starting of here, so any help would be greatly appreciated 🙂
Using
explodemakes it easy enough:The output is: