I have comma separated numbers in 1
database field (1,2,58,65) and want to check if $_SESSION['customer_id']
is in array, but don't know how to format $adminids
to get it work. It works with 1 number, but not with more than 1. I already tried other methods than in_array, but I always fail.
This is my code.
$lsc_adminid_query = xtDBquery("SELECT lsc.option_id,
lsc.option_value
FROM lsc_config lsc
WHERE lsc.option_id = 27");
while ($adminid_query = xtc_db_fetch_array($lsc_adminid_query)) {
if (xtc_not_null($adminid_query['option_value'])) {
$adminids = $adminid_query['option_value'];
}
}
$lsc_cid = array($adminids);
if (in_array($_SESSION['customer_id'], $lsc_cid)) {
$lsc_admin = "lsc_admin";
if (!isset($_COOKIE[$lsc_admin])) {
setcookie($lsc_admin, '1', time() + (7200), "/");
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…