function twig_replace_filter in Translation template extractor 7.3
Replaces strings within a string.
Parameters
string $str String to replace in:
array|Traversable $from Replace values:
string|null $to Replace to, deprecated (@see http://php.net/manual/en/function.strtr.php):
Return value
string
1 string reference to 'twig_replace_filter'
- Twig_Extension_Core::getFilters in vendor/
Twig/ Extension/ Core.php - Returns a list of filters to add to the existing list.
File
- vendor/
Twig/ Extension/ Core.php, line 534
Code
function twig_replace_filter($str, $from, $to = null) {
if ($from instanceof Traversable) {
$from = iterator_to_array($from);
}
elseif (is_string($from) && is_string($to)) {
@trigger_error('Using "replace" with character by character replacement is deprecated and will be removed in Twig 2.0', E_USER_DEPRECATED);
return strtr($str, $from, $to);
}
elseif (!is_array($from)) {
throw new Twig_Error_Runtime(sprintf('The "replace" filter expects an array or "Traversable" as replace values, got "%s".', is_object($from) ? get_class($from) : gettype($from)));
}
return strtr($str, $from);
}