There is nothing wrong.
I did run it with no errors.
But when you make
$y = new HTML_Table(x,x,x,x,x,x,$myarr);
Make sure that it is really an array you enter for CLASS: $attr_ar
Because if it is not, then the function will complain
as [man]foreach[/man] always expect an array to loop with
Here is my test:
<?php
class HTML_Table {
private $rows = array();
private $tableStr = '';
function __construct($id = NULL, $klass = NULL, $border = 0, $cellspacing = 2, $cellpadding = 0, $attr_ar = array() ) {
$this->tableStr = "\n<table" . ( !empty($id)? " id=\"$id\"": '' ) .
( !empty($klass)? " class=\"$klass\"": '' ) . $this->addAttribs( $attr_ar ) .
" border=\"$border\" cellspacing=\"$cellspacing\" cellpadding=\"$cellpadding\">\n";
}
private function addAttribs( $attr_ar ) {
$str = '';
foreach( $attr_ar as $key => $val ) {
$str .= " $key=\"$val\"";
}
return $str;
}
}
///// test
$x = new HTML_Table();
?>