You are here

protected function SendGridMailSystem::_get_substring in SendGrid Integration 7

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.

Swiped from SMTP module. Thanks!

Parameters

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

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

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

$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 SendGridMailSystem::_get_substring()
SendGridMailSystem::mail in inc/sendgrid.mail.inc
Implement mail method to send mail via Sendgrid.

File

inc/sendgrid.mail.inc, line 528
Implements Drupal MailSystemInterface.

Class

SendGridMailSystem
@file Implements Drupal MailSystemInterface.

Code

protected function _get_substring($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 = drupal_substr($source, $first_character, $second_character - $first_character);
  $string_length = drupal_strlen($substring) - 1;
  if ($substring[$string_length] == $ending_character) {
    $substring = drupal_substr($substring, 0, $string_length);
  }
  return $substring;
}