Im not sure whats wrong with this code, but I cant make it work. I'm trying to verify if multiple email addresses exists in user table.
Here is my code:
(
[email] => Array
(
[0] => jim@mail.com
[1] => peter@mail.com
[2] => john@mail.com
)
)
array_filter($_POST['email']);
function _implode($array)
{
$result = array();
foreach ($array as $row) {
if ($row != '') {
array_push($result, $row);
}
}
return implode(",", $result);
}
$emails = _implode(array_map(function($str) { return sprintf("'%s'", $str); }, $_POST['email']));
$users = $db->query("SELECT email FROM users WHERE email IN(" . $emails . ")");
Please note that I'm using PDO driver