is there an "in" qualifier in PHP?

From: Date: Tue, 26 Feb 2002 16:34:01 +0000
Subject: is there an "in" qualifier in PHP?
Groups: php.general 
Request: Send a blank email to php-general+get-86266@lists.php.net to get a copy of this message
I have a problem with some code (posted below), which I think I can solve using a method similar to that found in Python: if ($item in $potential_items) { // do one thing } else { // do another } Is there something like this available in PHP? Thank you, Erik If you wish to see more detail, I am trying to execute code that is very similar to the following: <?php // in this example, $selected_users is an array of strings that have been // selected from a multiple listbox in the previous instantiation of the // page. I am redisplaying the form because the user has made a mistake, // but trying to get those same strings to be "selected='yes'" in the new // form. $db = // mysql connection parameters $sql = "SELECT id, name FROM users ORDER BY id ASC"; $result = mysql_query($sql, $db); $c = 0; // this is a counter for the while loop while ($row = mysql_fetch_assoc($result)) { if ($row['id'] == $selected_users["$c"]) { echo "<option value=\"{$row['id']}\" selected=\"yes\">{$row['name']}</option>"; } else { echo "<option value=\"{$row['id']}\">{$row['name']}</option>"; } $c++; // bump up the counter for the next iteration of the fetched $row } ?> ---- Erik Price Web Developer Temp Media Lab, H.H. Brown pricee@hhbrown.com

« previous php.general (#86266) next »