Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

twig replace some chars by *

{% macro redact(topSecret) %}
    {% set length = topSecret|length - 4 %}
    {{ topSecret|slice(0, 3) }}{% for i in 0..length %}*{% endfor %}
{% endmacro %}

{# You have to import from _self if the macro is declared in the same file. #}
{% import _self as sharpie %}

{{ sharpie.redact('Top secret information') }}
{# => Top******************* #}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #twig #replace #chars
ADD COMMENT
Topic
Name
4+1 =