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.
精彩评论