Jump to content

[SOLVED] Array in if conditional


laPistola

Recommended Posts

<?php
// Check if blocked
$CBs = explode(',',$row_checkBlockedRS['blocked']);
$CBa = array();
foreach($CBs as $key => $value) {
array_push($CBa,$value);
}

if ($row_memberRS['id']==$CBa) {
header("location: errors.php?status=blocked");
}
?>

 

Im trying to make a condition in an if check to see if its value is in an array, i have checked everything and $row_memberRS['id'] = 1 and the array to $CBa looks like 1,1,1,1 so the condition in the if should read true or can you not check to see if a value lies in an array this way?

Link to comment
https://forums.phpfreaks.com/topic/134777-solved-array-in-if-conditional/
Share on other sites

there not in an array its a string of data that taken straight from a DB field also i didn't think it would as easy as array($row) ???

 

anyway it works now thank you, i did in_array before i posted but got an error that made me think it wasn't the one to use, after the link to the manual i realised it was just the way i did it  :-\

 

Thank you

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.