title: fpdf want to change SetFillColor for an array dependent on if/else statement
body: <p>Ok, will try be as clear as possible here. I am trying to produce a pdf document with various fields that display product information. Essentially, the script that produces the pdf will determine whether a change in the product has been initiated, if it has then the pdf will be created.</p>
  
  <p>What I am trying to do now is highlight the field with those changes. To check whether there are changes I am using the following variables (of which there are about thirty)</p>
  
  <pre><code>$cone
  $ctwo..... etc
  </code></pre>
  
  <p>An example of the array for the product output in the PDF file is:</p>
  
  <pre><code>    $leftHeadArray[0]['leftText']  = 'ID';
      $leftHeadArray[0]['rightText'] = $ID;
  
  
      $leftHeadArray[1]['leftText']  = 'start';
      $leftHeadArray[1]['rightText'] = date("d/m/Y", $Start);
  
  
      $leftHeadArray[2]['leftText']  = 'End';
      $leftHeadArray[2]['rightText'] = date("d/m/Y", $End);
  </code></pre>
  
  <p>The format and cell is then initated below this at:</p>
  
  <pre><code>$maxheader = max(array_keys($leftHeadArray), array_keys($midHeadArray), array_keys($rightHeadArray));
  
      for ($i = 0; $i &lt;= max($maxheader); $i++)
      {
          if (isset($leftHeadArray[$i]))
          {
              $pdf-&gt;SetFont('helvetica', 'B', 6);
              $pdf-&gt;SetFillColor(128, 0, 0);
              $pdf-&gt;SetTextColor(255, 255, 255);
  
              $pdf-&gt;Cell(40, 5, $leftHeadArray[$i]['leftText'], $border, 0, 'L', 1);
  
              $pdf-&gt;SetFont('helvetica', 'N', 6);
              if ($ctwentytwo == 0 &amp;&amp; $leftHeadArray[1]['rightText'] || $ctwentytwo == 0 &amp;&amp; $leftHeadArray[4]['rightText'] ){
              $pdf-&gt;SetFillColor(255, 255, 255);
              $pdf-&gt;SetTextColor(0, 0, 0);
              }else{
              $pdf-&gt;SetFillColor(0, 0, 0);
              $pdf-&gt;SetTextColor(255, 255, 255);
              }
  
          $pdf-&gt;Cell(30, 5, $leftHeadArray[$i]['rightText'], $border, 0, 'L', 1);
          $pdf-&gt;Cell(20, 5, '', 0, 0, 'L', 0);
      }
  </code></pre>
  
  <p><strong>Things I have tried already:</strong></p>
  
  <ol>
  <li><p>wrapping if else statements around the inidividual cell arrays </p>
  
  <p>(e.g. $leftHeadArray[0]['leftText']  = 'ID';
          $leftHeadArray[0]['rightText'] = $ID;)</p>
  
  <p>and trying to over-ride the set fill color within there</p></li>
  <li><p>putting the if else statement within the if isset section</p></li>
  </ol>
  
  <p><strong>Things I am struggling with:</strong></p>
  
  <ul>
  <li>connecting the $cone to the $leftheadarray </li>
  <li>changing just the one cell when a change is initiated</li>
  </ul>
  
  <p>I hope this is concise!</p>
  
  <p>//------------------------------ RESOLVED</p>
  
  <p>The variable is always assumed as 0 so needed to make the declatation if $cone == 1 and relate back to the left head array as below: hope this helps!</p>
  
  <pre><code>if (isset($leftHeadArray[$i]))
          {
              $pdf-&gt;SetFont('helvetica', 'B', 6);
              $pdf-&gt;SetFillColor(128, 0, 0);
              $pdf-&gt;SetTextColor(255, 255, 255);
  
              $pdf-&gt;Cell(40, 5, $leftHeadArray[$i]['leftText'], $border, 0, 'L', 1);
  
              $pdf-&gt;SetFont('helvetica', 'N', 6);
  
              $pdf-&gt;SetFillColor(255, 255, 255);
              $pdf-&gt;SetTextColor(128, 0, 0);
  
  
              if (($ctwentytwo == 1) &amp;&amp; ($leftHeadArray[$i]['leftText'] == "Promotion Start Date")
              ||  ($cone == 1) &amp;&amp; ($leftHeadArray[$i]['leftText'] == "Promotion ID")
              ||  ($ctwo == 1) &amp;&amp; ($leftHeadArray[$i]['leftText'] == "Promotion Type"))#|| $ctwentytwo == 0 &amp;&amp; $leftHeadArray[1]['rightText']
              {
                  $pdf-&gt;SetFillColor(0, 0, 0);
                  $pdf-&gt;SetTextColor(255, 255, 255);
              }
  
              $pdf-&gt;Cell(30, 5, $leftHeadArray[$i]['rightText'], $border, 0, 'L', 1);
              $pdf-&gt;Cell(20, 5, '', 0, 0, 'L', 0);
          }
  </code></pre>