Page 491 - Beginning PHP 5.3
P. 491
Chapter 15: Making Your Job Easier with PEAR
$table->addRow( array( “Sequence #”, “Value” ), null, “th” );
$iterations = 10;
$num1 = 0;
$num2 = 1;
$table->addRow( array( “F<sub>0</sub>”, “0” ) );
$table->addRow( array( “F<sub>1</sub>”, “1” ) );
for ( $i=2; $i <= $iterations; $i++ )
{
$sum = $num1 + $num2;
$num1 = $num2;
$num2 = $sum;
$table->addRow( array( “F<sub>$i</sub>”, $num2 ) );
}
$attrs = array( “class” => “alt” );
$table->altRowAttributes( 1, null, $attrs, true );
echo $table->toHtml();
?>
</body>
</html>
When you run the script, you should see a page more or less the same as the one produced by the
script in Chapter 4. Figure 15-2 shows the result.
Figure 15-2
453
9/21/09 9:14:51 AM
c15.indd 453
c15.indd 453 9/21/09 9:14:51 AM