51ff3226 |
1 | <?php |
2 | function smarty_function_str_split($params,&$smarty) { |
3 | if (!function_exists("str_split")) { |
4 | function str_split($str,$length = 1) { |
5 | if ($length < 1) return false; |
6 | $strlen = strlen($str); |
7 | $ret = array(); |
8 | for ($i = 0; $i < $strlen; $i += $length) { |
9 | $ret[] = substr($str,$i,$length); |
10 | } |
11 | return $ret; |
12 | } |
13 | } |
14 | |
15 | $name = $params['name']; |
16 | if (!empty($name)) $array[$name] = str_split($params['string'],$params['length']); |
17 | else $array = str_split($params['string'],$params['length']); |
18 | $smarty->assign('str_split',$array); |
19 | } |
20 | ?> |