Answers for "php remove string from the end of string"

PHP
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
0

remove exact characters from string using php

$widget_id = substr($widget_text, 1, strlen($widget_text)-2);
Posted by: Guest on October-22-2021

Code answers related to "php remove string from the end of string"

Browse Popular Code Answers by Language