I have a very simple code which replaces specific values in a string and then explodes it.
But i need to do a count on the string after exploding, Here is my example
$exclude=array();
$exclude[0]="with";
$exclude[1]="on";
$search_string="Boy with a t-shirt walking on the road";
echo str_word_count($search_string);
//the str_replace is suppose to remove the word "with" and "on" from string
// count search string before explode
$sch2 = str_replace($exclude,"", trim($search_string));
$sch=explode(" ",trim($sch2));
echo count($sch);
//count search string after explode
//The result of the second count after exploding is suppose to be 6 and NOT 8
But when i count the $sch string after exploding, it gives me 8
It seems like there is something am doing wrong, any help will be appreciated. thanks
var_dump($sch);- perhaps $sch doesn't contain what you think it does?