Jump to content

[SOLVED] if else


Schlo_50

Recommended Posts

Hello,

 

I have the folowing code which check to see if my variables are null or not. However if all of my variables are null then as the script continues it generates errors. Is there any way using what I have below, to make it so that the rest of the script isn't run if all of my variables are null?

 

$arrString = array();
if(!is_null($relevanta))
$arrString[] = $relevanta;
if(!is_null($relevantb))
$arrString[] = $relevantb;
if(!is_null($relevantc))
$arrString[] = $relevantc;
if(!is_null($relevantd))
$arrString[] = $relevantd;
if(!is_null($relevante))
$arrString[] = $relevante;
if(!is_null($relevantf))
$arrString[] = $relevantf;

$srt_string = implode(",", $arrString);

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/108542-solved-if-else/
Share on other sites

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.