this is a sentence oil on a line
this is another sentence
another one
hey oil sentence
I have these 4 sentences, what I want to do is to check if this sentence(each sentence is on a line) has the word oil
. And if it does I would delete the whole sentence.
So I'll End up with this:
this is another sentence
another one
the lines including oil
has been removed.
I had an idea of exploding
these lines to an array. Then use foreach
to check for oil
. Deleting the element, then imploding
.
But I was wondering if there are any faster ways?