You are here

function _quiz_get_last_table_rows in Quiz 8.4

Same name and namespace in other branches
  1. 6.4 quiz.admin.inc \_quiz_get_last_table_rows()
  2. 7 quiz.admin.inc \_quiz_get_last_table_rows()
  3. 7.4 quiz.admin.inc \_quiz_get_last_table_rows()

Finds and returns the last table rows(HTML) in a table(HTML)

TODO: DELETE

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)

File

./quiz.admin.inc, line 2186
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;
}