匹配所有除了一些单词

i'm looking for a way, to match all except the some word.

please tell me how i must wrote it?

when i wrote

$str = "i am a programmer";
$word = "am";
preg_match_all("/[^($word)]/", $str, $matched);// it do the same, if i when i wrote
preg_match_all("/[^$word]/", $str, $matched);

i also tried preg_match_all("/[^{$word}]/", $str, $matched); but it doesn't do the job.

how can i tell all except that word ?

Thanks Much

Can't you simply remove all occurrences of the word?

str_replace($word, '', $str);

Or split using explode() or preg_split()? This will give you an array with all parts separated by the word.