You are here

protected function SMTPMailSystem::getSubstring in SMTP Authentication Support 8

Returns a string that is contained within another string.

Returns the string from within $source that is some where after $target and is between $beginning_character and $ending_character.

Parameters

string $source: A string containing the text to look through.

string $target: A string containing the text in $source to start looking from.

string $beginning_character: A string containing the character just before the sought after text.

string $ending_character: A string containing the character just after the sought after text.

Return value

string A string with the text found between the $beginning_character and the $ending_character.

1 call to SMTPMailSystem::getSubstring()
SMTPMailSystem::mail in src/Plugin/Mail/SMTPMailSystem.php
Send the e-mail message.

File

src/Plugin/Mail/SMTPMailSystem.php, line 768

Class

SMTPMailSystem
Modify the drupal mail system to use smtp when sending emails.

Namespace

Drupal\smtp\Plugin\Mail

Code

protected function getSubstring($source, $target, $beginning_character, $ending_character) {
  $search_start = strpos($source, $target) + 1;
  $first_character = strpos($source, $beginning_character, $search_start) + 1;
  $second_character = strpos($source, $ending_character, $first_character) + 1;
  $substring = substr($source, $first_character, $second_character - $first_character);
  $string_length = strlen($substring) - 1;
  if ($substring[$string_length] == $ending_character) {
    $substring = substr($substring, 0, $string_length);
  }
  return $substring;
}