I'm new in PHP programming. I need your help to finish my homework.
I want to explode the following sentence: I love my band and my cat into arrays.
But I need to use space and word and as delimiters. So it should become like this:
$arr[0] -> I
$arr[1] -> love
$arr[2] -> my
$arr[3] -> band
$arr[4] -> my
$arr[5] -> cat
I have tried like this:
$words = "I love my band and my cat"
$stopwords = "/ |and/";
$arr = explode($stopwords, $words);
But the problem is, it also removes characters and from word band so it becomes like this:
$arr[0] -> I
$arr[1] -> love
$arr[2] -> my
$arr[3] -> b
$arr[4] -> my
$arr[5] -> cat
This is not what I want. I want to remove the word that exactly and, not word that contains and characters.
Is there anyway to solve this? Can anybody help me? Thank you very much.. :-)