You are here

function replace in Porter-Stemmer 6

Same name and namespace in other branches
  1. 5 porterstemmer.module \replace()

Replaces the first string with the second, at the end of the string. If third arg is given, then the preceding string must match that m count at least.

Parameters

string $str String to check:

string $check Ending to check for:

string $repl Replacement string:

int $m Optional minimum number of m() to meet:

Return value

bool Whether the $check string was at the end of the $str string. True does not necessarily mean that it was replaced.

6 calls to replace()
step1ab in ./porterstemmer.module
Step 1
step1c in ./porterstemmer.module
Step 1c
step2 in ./porterstemmer.module
Step 2
step3 in ./porterstemmer.module
Step 3
step4 in ./porterstemmer.module
Step 4

... See full list

File

./porterstemmer.module, line 346

Code

function replace(&$str, $check, $repl, $m = null) {
  $len = 0 - strlen($check);
  if (substr($str, $len) == $check) {
    $substr = substr($str, 0, $len);
    if (is_null($m) or m($substr) > $m) {
      $str = $substr . $repl;
    }
    return true;
  }
  return false;
}