In that case you would probably want to use the .join function to assign the values to a single variable, and then use that variable in your sql statement.
//something like
$foo = join(" ", $names);
//and assuming you already have a connection open to your db
mysql_query("SELECT field FROM table WHERE (field REGEXP '$foo'));
Then again, it may be good to check the field against each value seperatly in which case I would probably build part of the sql statement into a loop:
//something like
$sql = "SELECT field FROM table WHERE ";
reset($names);
for($i=0; $i<sizeof($names); $i++) {
if ($i != 0) {
$sql .= " OR ";
}
$sql .= "(field REGEXP '" . $names[$i] . "')";
}
$slq .= " ORDER BY field";
mysql_query($sql) or die(mysql_error());
Notice in the second example I used a for loop instead of a foreach loop. This is because I wanted to use a counter to identify when we are looking at the first record. Once again bothe examples are of the assumption that you have already connected to your mysql database via mysql_connect().
Does this answer your question?