String Repeat

Author: Ken Stanley <>

This plugin gives you the same results as the native PHP function str_repeat does. There

are three attributes to the function: STRING (String to repeat) and COUNT (How many times to repeat) and ASSIGN which allows you to stuff the results into a template variable to use

as many times throughout the template as you wish.


 * Smarty plugin
 * -------------------------------------------------------------
 * Type:     function
 * Name:     str_repeat
 * Author:   Ken Stanley <>
 * Purpose:  print out a value x amount of times
 * -------------------------------------------------------------
function smarty_function_str_repeat($params, &$smarty)
    static $string = array();
    static $count = array();
    static $assign = "";

    if (!empty($assign))
        $smarty->assign($assign, str_repeat($string[0],$count[0]));
        echo str_repeat($string[0],$count[0]);

Back to SmartyPlugins?.