I have an array of strings, and want to remove all elements from the array which contain the word "Free_Course"
the array holds strings such as "Free_Course_123", "Free_Course_124", "Other_Course_123", Other_Course_1234 etc..
I just want to loop through the array, and remove all containing "Free_Course", so this would get rid of the first 2 elements listed above.
I've tried using this preg_grep funciton, but had no success as of yet:
$cleanTags= preg_grep("/^Free_Course*/", $tags);
^at the start of a regex pattern is NOT an inversion. it's the "start of string" anchor. It's an inversion only when at the start of a character class, e.g.[^xyz](anything except x/y/z). your regex as written will simply return an array the very things you're trying to remove - all entries that start withFree_Course.