table_altrow.module in Table Alternate Rows 8
Same filename and directory in other branches
Insert even and odd classes for tables via input filters to allow for proper zebra-style striping.
File
table_altrow.moduleView 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
Name | 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 |