function _quiz_get_last_table_rows in Quiz 7
Same name and namespace in other branches
- 8.4 quiz.admin.inc \_quiz_get_last_table_rows()
- 6.4 quiz.admin.inc \_quiz_get_last_table_rows()
- 7.4 quiz.admin.inc \_quiz_get_last_table_rows()
Finds and returns the last table rows(HTML) in a table(HTML)
Parameters
$table: HTML string with a table
$num_rows: The number of rows to return(int)
Return value
last table row in the table(html string)
1 call to _quiz_get_last_table_rows()
- quiz_browser_ahah in ./
quiz.admin.inc - AHAH handler for the question browser
File
- ./
quiz.admin.inc, line 2613 - Administrator interface for Quiz module.
Code
function _quiz_get_last_table_rows($table, $num_rows = 1) {
$matches = array();
$num_matches = preg_match_all('/<tr.*?<\\/tr>/is', $table, $matches);
$to_return = '';
$num_rows_to_return = $num_matches > $num_rows ? $num_rows : $num_matches;
for ($i = $num_matches - 1; $i > $num_matches - 1 - $num_rows_to_return; $i--) {
$to_return .= $matches[0][$i];
}
return $to_return;
}