I am searching an array for instances of words or partial words. I need to have the regular expression check to make sure that there is a -space- at the beginning. This way- it will not count matches of the string in the middle of words.
here is what I have tried;
$search_var = "sil";
$match = preg_grep("/$search_var/i", $my_array);
//this was the original that led me to have to check for the space at the beginning.
//
//so I tried;
$match = preg_grep("/^([:space:])$search_var/i", $my_array);//DID NOT WORK
I know I am making a stupid error- but for the life of me- I cannot figure it out.