- preg_match_all: documentation ( source)
<?php
$text = <<<TEXT
I like foo << - not allowed
I like fooSomeRandomString << - not allowed
I like food << - allowed
I like football << - allowed
I like drawing << - allowed
I dislike drawing << - not allowed
TEXT;
$pattern = '#I like (?<like>(?!foo(?!d|tball))[^ ]+)#';
preg_match_all($pattern, $text, $matches);
foreach($matches['like'] as $like) {
echo $like . PHP_EOL;
}