i am trying to beautify output of join two strings in a cell.
i am using the following line so far.
Code:
$pdf->Cell($width_cell[2],5,$row['month_01_A'] . ' - ' . $row['month_01_B'],0,0,'R');
Output:
129 - 10
50 - 120
231 - 5
I would like to have an alignment in -
and have the desire output:
129 - 10
50 - 120
231 - 5
I was think to use if
or switch
and count length of $row['month_01_A']
and $row['month_01_B']
and output the desire spacing in -
.
Tried the following code(fixing the second part) but didn't work:
$t=strlen($row['month_01_B']);
switch ($t) {
case "1":
$mmm=$row['month_01_A'] . '- ' .$row['month_01_B'];
case "2":
$mmm=$row['month_01_A'] . '- ' .$row['month_01_B'];
case "3":
$mmm=$row['month_01_A'] . '-' .$row['month_01_B'];
default:
$mmm="000";
}
$pdf->Cell($width_cell[2],5,$mmm,0,0,'R');
I am getting this output always:
000
I made it and i have two solutions. One is with working code above.
$t=strlen($row['month_01_B']);
switch ($t) {
case "1":
$mmm=$row['month_01_A'] . '- ' .$row['month_01_B'];
break;
case "2":
$mmm=$row['month_01_A'] . '- ' .$row['month_01_B'];
break;
case "3":
$mmm=$row['month_01_A'] . '-' .$row['month_01_B'];
break;
default:
$mmm="000";
}
$pdf->Cell($width_cell[2],5,$mmm,0,0,'R');
Second is to split my cell into 3. The first cell for value A, the second for my symbol and last one for my second value B.