Ecco come procedere:
$count = count($first_names);
$in_params = trim(str_repeat('?, ', $count), ', ');
$query = "SELECT mytable_id_pk
FROM mytable
WHERE mytable_fname IN ({$in_params});";
$stmt = $DB->Prepare($query);
$result = $DB->Execute($stmt, $first_names);
Poiché il numero di placeholder in una clausola IN è dinamico, questo codice costruisce il numero corretto di ? in base alla lunghezza dell’array prima di preparare lo statement.
Se usi PDO, puoi ottenere lo stesso risultato con str_repeat('?, ', $count) e execute($first_names).