Using PHP's preg_match to see if a value matches a list of values
<p>I want to see if a variable contains a value that matches one of a few values in a hard-coded list. I was using the following, but recently found that it has a flaw somewhere:</p>

<pre><code>if (preg_match("/^(init)|(published)$/",$status)) {
    echo 'found';
} else {
    echo 'nope';
}
</code></pre>

<p>I find that if the variable $status contains the word "unpublished" there is still a match even though 'unpublished' is not in the list, supposedly because the word 'unpublished' contains the word 'published', but I thought the ^ and $ in the regular expression are supposed to force a match of the whole word. Any ideas what I'm doing wrong? </p>
