0

I have this fpdf and I am trying to print a cell only if a variable is equal to 5, then another cell when it is equal to 6. It is a form with questions where students must fill in the right answer.

this prints the rows with A B C D E (answers):

if ($row['tipo'] == "sc" OR $row['tipo'] == "sel")
        {
        $array_risposte = array( $row['risposta1'],$row['risposta2'],$row['risposta3'],$row['risposta4'],$row['risposta5'],$row['risposta6'],$row['risposta7'],$row['risposta8'],$row['risposta9'],$row['risposta10']);
        $array_filtrato = array_filter($array_risposte);
        $result2 = count($array_filtrato);


        $letterposition= array (' A',' A',' B',' C',' D',' E',' F',' G',' H',' I',' J');
        $position=1;
        while($position<=$result2)
          {
          $stampanumero = $letterposition[$position].$p->Image($image1, $p->GetX()+6, $p->GetY()+1);
          $p->Cell(14, 6, $stampanumero, 1, 0, 'L');
          //$domande .= $position." [ ] ";

          $position++;
          }
    }

It works perfectly. And on top I want to name the coloumns A B C D, and if there is an answer E, to print the coloumn E. (The coloumns ABCD are always there, no issue with that). My code doesn't print coloumn E:

if($letterposition[$position]=="5")
{       
$p->Cell(14, 5, $LetterE, 1, 0, 'L','true'); //RISPONSI
}

Thanks!

4

1 回答 1

1

$letterposition 是一个包含字母数组的数组。实际上 $letterposition[$position] 的值将是一个字母 'E' 而不是 '5'。

于 2012-09-05T10:09:12.710 回答