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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.