You are here

table_altrow.module in Table Alternate Rows 8

Same filename and directory in other branches
  1. 5 table_altrow.module
  2. 6 table_altrow.module
  3. 7 table_altrow.module

Insert even and odd classes for tables via input filters to allow for proper zebra-style striping.

File

table_altrow.module
View source
<?php

/**
 * @file
 * Insert even and odd classes for tables via input filters to allow for proper
 * zebra-style striping.
 */

/**
 * Replace every instance of a string with a count parameter like PHP5.
 * This can probably be removed with Drupal goes to PHP5 only.
 * Shamelessly stolen and modified from
 * http://ca.php.net/manual/en/function.str-replace.php#76180
 *
 * @param $needle
 *   The string to search for.
 * @param $replace
 *   The string to replace.
 * @param $haystack
 *   The text to search within.
 * @param $offset
 *   Optional parameter to indicate the character position to start the search
 *   and replace at.
 * @param integer $count
 *   Optional parameter to indicate the number of times to execute replacements.
 *
 * @return
 *   The modified string.
 */
function table_altrow_str_replace_count($needle, $replace, $haystack, $offset = NULL, $count = NULL) {
  if ($count == null) {
    $count = 0;
    $offset = strpos($haystack, $needle);
  }
  $rpl_count = 0;
  while ($offset !== false && $rpl_count < $count) {
    $haystack = substr_replace($haystack, $replace, $offset, strlen($needle));
    $offset += strlen($replace);
    $offset = strpos($haystack, $needle, $offset);
    $rpl_count++;
  }
  return $haystack;
}

Functions

Namesort descending Description
table_altrow_str_replace_count Replace every instance of a string with a count parameter like PHP5. This can probably be removed with Drupal goes to PHP5 only. Shamelessly stolen and modified from http://ca.php.net/manual/en/function.str-replace.php#76180