Jump to content

If Statement help needed


LoopyLoo

Recommended Posts

Hi,

New to the forum so hello first!! Just starting out in php and joined here hoping to learn more. Sorry, if i'm asking dumb questions.

 

I need an If statement that does the following:

 

If $products_info['products_dcc'] is empty then echo some html/text....

 

So far I have this:

 

if ($products_info['products_dcc'] = "") {

  echo "<p><b>DCC Info: " . $product_info['products_dcc'] . "</b></p>";

}

 

Thanks in advance!

Lucy.

Link to comment
https://forums.phpfreaks.com/topic/126684-if-statement-help-needed/
Share on other sites

Make sure its..

 

if ($products_info['products_dcc'] == "") 

 

instead of...

 

if ($products_info['products_dcc'] = "") {

 

you can also use the follow function...

 

if (!isset($products_info['products_dcc'])) {

 

isset() only works if the variable had not been set at all. If it was set, but empty, will still evaluate to true.

Archived

This topic is now archived and is closed to further replies.

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