modules/acm/src/ACMAddressFormatter.php
public static function replacePlaceholders($string, array $replacements) {
    // Make sure the replacements don't have any unneeded newlines.
    $replacements = array_map('trim', $replacements);
    $string = strtr($string, $replacements);
    // Remove noise caused by empty placeholders.
    $lines = explode("\n", $string);
    foreach ($lines as $index => $line) {
      // Remove leading punctuation, excess whitespace.
      $line = trim(preg_replace('/^[-,]+/', '', $line, 1));
      $line = preg_replace('/\s\s+/', ' ', $line);
      $lines[$index] = $line;
    }
    // Remove empty lines.
    $lines = array_filter($lines);

    return implode("\n", $lines);
  }
public static function replacePlaceholders($string, array $replacements) {
    // Make sure the replacements don't have any unneeded newlines.
    $replacements = array_map('trim', $replacements);
    $string = strtr($string, $replacements);
    // Remove noise caused by empty placeholders.
    $lines = explode("\n", $string);
    foreach ($lines as $index => $line) {
      // Remove leading punctuation, excess whitespace.
      $line = trim(preg_replace('/^[-,]+/', '', $line, 1));
      $line = preg_replace('/\s\s+/', ' ', $line);
      $lines[$index] = $line;
    }
    // Remove empty lines.
    $lines = array_filter($lines);

    return implode("\n", $lines);
  }
public static function replacePlaceholders ( $ string , array $ replacements ) { // Make sure the replacements don't have any unneeded newlines. $ replacements = array_map ( 'trim' , $ replacements ) ; $ string = strtr ( $ string , $ replacements ) ; // Remove noise caused by empty placeholders. $ lines = explode ( "\n" , $ string ) ; foreach ( $ lines as $ index => $ line ) { // Remove leading punctuation, excess whitespace. $ line = trim ( preg_replace ( '/^[-,]+/' , '' , $ line , 1 ) ) ; $ line = preg_replace ( '/\s\s+/' , ' ' , $ line ) ; $ lines [ $ index ] = $ line ; } // Remove empty lines. $ lines = array_filter ( $ lines ) ; return implode ( "\n" , $ lines ) ; }
Replaces placeholders in the given string.

@param string $string
The string containing the placeholders.
@param array $replacements
An array of replacements keyed by their placeholders.

@return string
The processed string.
Replaces placeholders in the given string .