function twig_urlencode_filter

URL encodes a string as a path segment or an array as a query string.

Parameters

string|array $url A URL or an array of query parameters:

bool $raw true to use rawurlencode() instead of urlencode:

Return value

string The URL encoded value

1 string reference to 'twig_urlencode_filter'
Twig_Extension_Core::getFilters in drupal/core/vendor/twig/twig/lib/Twig/Extension/Core.php
Returns a list of filters to add to the existing list.

File

drupal/core/vendor/twig/twig/lib/Twig/Extension/Core.php, line 525

Code

function twig_urlencode_filter($url, $raw = false) {
  if (is_array($url)) {
    return http_build_query($url, '', '&');
  }
  if ($raw) {
    return rawurlencode($url);
  }
  return urlencode($url);
}