You are here

public static function FeedImportFilter::startsWith in Feed Import 8

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

Check if a string starts 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 345

Class

FeedImportFilter
This class contains default filters for feed import.

Namespace

Drupal\feed_import_base

Code

public static function startsWith($field, $what, $insensitive = FALSE) {
  if ($insensitive) {
    return stripos($field, $what) === 0 ? $field : NULL;
  }
  return strpos($field, $what) === 0 ? $field : NULL;
}