How to use array variables as defined variables in PHP? -
i declared array
$clists=array("add_product"=>"products.php","payment_type"=>"payment.php","shipping"=>"shipping.php"); and defined variables
<?php define("add_product",true); define("payment_type",false); define("shipping",false); foreach($clists $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. div strikes. did mistake?
define not think does. define creates named constant.
and cannot alter array variables it.
simply do:
$clists['add_product'] = true; $clists['payment_type'] = false; $clists['shipping'] = false; to alter array variables.
php arrays
No comments:
Post a Comment