} elseif ( is_int( $value ) ) {
$s = $value;
} elseif ( is_array( $value ) && // Make sure it's not associative.
- array_keys($value) === range(0,count($value)-1)
+ array_keys($value) === range( 0, count($value) - 1 ) ||
+ count($value) == 0
) {
$s = '[';
foreach ( $value as $elt ) {
foreach( $headers as $id => $header ) {
$attribs = array();
if ( is_string( $id ) ) $attribs['id'] = $id;
- if ( is_array( $id ) ) $attribs = $id;
$s .= Xml::element( 'th', $attribs, $header );
}
}
foreach( $rows as $id => $row ) {
$attribs = array();
if ( is_string( $id ) ) $attribs['id'] = $id;
- if ( is_array( $id ) ) $attribs = $id;
$s .= Xml::buildTableRow( $attribs, $row );
}
$s .= Xml::closeElement( 'table' );
/**
* Build a row for a table
+ * @param $attribs An array of attributes to apply to the tr tag
* @param $cells An array of strings to put in <td>
* @return string
*/
foreach( $cells as $id => $cell ) {
$attribs = array();
if ( is_string( $id ) ) $attribs['id'] = $id;
- if ( is_array( $id ) ) $attribs = $id;
$s .= Xml::element( 'td', $attribs, $cell );
}
$s .= Xml::closeElement( 'tr' );