public static function replace(string $string, array $data = []): string
    {
        $expressionLanguage = new ExpressionLanguage;
        preg_match_all('/\%([a-z0-9_\[\]\"\.]+)\%/i', $string, $matches);
        $placeholders = array_unique($matches[1]);
        $translations = [];

        foreach ($placeholders as $placeholder) {
            $translations['%'.$placeholder.'%'] = $expressionLanguage->evaluate($placeholder, $data);
        }

        $string = strtr($string, $translations);

        return $string;
    }
public static function replace(string $string, array $data = []): string
    {
        $expressionLanguage = new ExpressionLanguage;
        preg_match_all('/\%([a-z0-9_\[\]\"\.]+)\%/i', $string, $matches);
        $placeholders = array_unique($matches[1]);
        $translations = [];

        foreach ($placeholders as $placeholder) {
            $translations['%'.$placeholder.'%'] = $expressionLanguage->evaluate($placeholder, $data);
        }

        $string = strtr($string, $translations);

        return $string;
    }
public static function replace ( string $ string , array $ data = [ ] ) : string { $ expressionLanguage = new ExpressionLanguage ; preg_match_all ( '/\%([a-z0-9_\[\]\"\.]+)\%/i' , $ string , $ matches ) ; $ placeholders = array_unique ( $ matches [ 1 ] ) ; $ translations = [ ] ; foreach ( $ placeholders as $ placeholder ) { $ translations [ '%' . $ placeholder . '%' ] = $ expressionLanguage -> evaluate ( $ placeholder , $ data ) ; } $ string = strtr ( $ string , $ translations ) ; return $ string ; }
Replace parameter placeholders with data

@param string $string
@param array $data
@return string
Replace parameter placeholders with data