Answers for "php remove substring start end"

PHP
6

php pop off the first character of string

$str = substr($str, 1);
Posted by: Guest on September-10-2020
1

php remove stop words from string

public function optimizeSearchString($searchString = "")
  {
    $stopwords = array(
      'der' => 1,
      'die' => 1,
      'das' => 1,
      'the' => 1);

    $words = preg_split('/[^-\w\']+/', $searchString, -1, PREG_SPLIT_NO_EMPTY);

    if (count($words) > 1) {
      $words = array_filter($words, function ($v) use (&$stopwords) {
        return !isset($stopwords[strtolower($v)]);
      }
      );
    }

    if (empty($words)) {
      return $searchString;
    }

    return implode(" ", $words);
  }
Posted by: Guest on September-02-2020

Code answers related to "php remove substring start end"

Browse Popular Code Answers by Language