Answers for "remove string 0 php"

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
2

php remove string from array

$index = array_search('string3',$array);
if($index !== FALSE){
    unset($array[$index]);
}
Posted by: Guest on November-07-2021

Browse Popular Code Answers by Language