Jump to content

Foreach loop, maybe I'm missing something?


Zurev

Recommended Posts

foreach ($export as $group => $arrayOpts) 
	{
		//echo $arrayOpts[0]["choice"]; This returns No
		/**
		  * If the option hasn't been selected, leave that part out entirely
		 **/		
		if (!empty($arrayOpts)) // if the entire options array isn't empty, we'll display
		{
		   if ($arrayOpts[0]["choice"]!="0" || $arrayOpts[0]["choice"]!="No")
		   {
				$pdf->Cell(40,10,$group,0,1); 
				$pdf->ImprovedTable($header,$arrayOpts);
				$pdf->Ln();
		   }
		}
	}

 

Unfortunately I can't show print_r's at the moment, the main issue is it's running those $pdf-> lines even if that variable is equal to No, I proved it because up above commented out returns No, but it still runs the pdf code.

 

Any thoughts? Been staring at it a while, maybe it's something in my conditional statement? Thanks.

Link to comment
https://forums.phpfreaks.com/topic/224367-foreach-loop-maybe-im-missing-something/
Share on other sites

Presuming you don't want the value to be either zero or 'no':

if ($arrayOpts[0]["choice"]!="0" && $arrayOpts[0]["choice"]!="No")

 

I can't test it, but it seems that'll work. I honestly stared at those lines for a solid 1.5 hours today.  :'(

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.