I am trying to rearrange an if...else statement to include an array. Originally, if the the statement were false (!) the else code would run.
Now I want the foreach statement to be true for an array code to run & if false the else code would run.
I am a bit confused by the (strtolower($build_list[$i]['cat_name']) element, which is probably why I have not had any success. I did try defining it as $value.
Original:
<?php
if(strtolower($build_list[$i]['cat_name'])!='test1'){
?>
<form>details not shown</form>
<?php
}else{
?>
<form>details not shown</form>
<?php
}
?>
My attempt:
<?php
$x=array("test1","test2");
if(strtolower($build_list[$i]['cat_name'])==$x)
foreach ($x as $value)
{
?>
<form>details not shown</form>
<?php
}else{
?>
<form>details not shown</form>
<?php
}
?>
Any positive comment appreciated!