laPistola Posted November 29, 2008 Share Posted November 29, 2008 <?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 More sharing options...
wildteen88 Posted November 29, 2008 Share Posted November 29, 2008 look in to in_array Link to comment https://forums.phpfreaks.com/topic/134777-solved-array-in-if-conditional/#findComment-701824 Share on other sites More sharing options...
DarkWater Posted November 29, 2008 Share Posted November 29, 2008 Why are you doing array_push() to make an array of things that are already in an array? o_O Link to comment https://forums.phpfreaks.com/topic/134777-solved-array-in-if-conditional/#findComment-701830 Share on other sites More sharing options...
laPistola Posted November 29, 2008 Author Share Posted November 29, 2008 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 https://forums.phpfreaks.com/topic/134777-solved-array-in-if-conditional/#findComment-701879 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.