I declared an array
$CLISTS=array("Add_Product"=>"products.php","Payment_Type"=>"payment.php","Shipping"=>"shipping.php");
and I defined variables
<?php
define("Add_Product",TRUE);
define("Payment_Type",FALSE);
define("Shipping",FALSE);
foreach($CLISTS as $lists=>$page)
{
if($lists==TRUE)
{
?>
<div class='alert' style="text-decoration:line-through;"><?php echo str_replace("_"," ",$lists);?></div>
<?php }
else
{
?>
<div class='alert'><a href="<?php echo $page;?>"><?php echo str_replace("_"," ",$lists);?></a></div>
<?php }
}
?>
Its not working. All the div is strikes. What I did mistake?
DEFINE
does not do what you think it does. Define creates a named constant.
And you cannot change your array variables with it.
Simply do:
$CLISTS['Add_Product'] = true;
$CLISTS['Payment_Type'] = false;
$CLISTS['Shipping'] = false;
To change your array variables.
You can write the logic like
foreach($CLISTS as $lists=>$page)
{
if($lists == 'Add_Product')
{
?>
Or even you can use ===
like
foreach($CLISTS as $lists=>$page)
{
if($lists === TRUE)
{
?>