You are here

public static function FeedImportFilter::endsWith in Feed Import 8

Same name in this branch
  1. 8 feed_import_base/filters/feed_import_default_filters.php \FeedImportFilter::endsWith()
  2. 8 feed_import_base/src/Filter/FeedImportFilter.php \Drupal\feed_import_base\FeedImportFilter::endsWith()

Check if a string ends with a specified substring

Parameters

string $field: The string to check on

string $what: The substring

bool $insensitive: Perform insensitive search

Return value

mixed Value of $field if TRUE

File

feed_import_base/src/Filter/FeedImportFilter.php, line 365

Class

FeedImportFilter
This class contains default filters for feed import.

Namespace

Drupal\feed_import_base

Code

public static function endsWith($field, $what, $insensitive = FALSE) {
  $len = strlen($field);
  $wlen = strlen($what);
  if ($insensitive) {
    return strripos($field, $what) + $wlen == $len ? $field : NULL;
  }
  return strrpos($field, $what) + $wlen == $len ? $field : NULL;
}