1<?php 2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 3// 4// All Rights Reserved. See copyright.txt for details and a complete list of authors. 5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 6// $Id$ 7 8/** 9 * Smarty plugin 10 * @package Smarty 11 * @subpackage plugins 12 */ 13 14/** 15 * Smarty substring modifier plugin 16 * 17 * Type: modifier<br> 18 * Name: substring<br> 19 * Purpose: Returns a substring of string. Same arguments as 20 * PHP substr function. 21 * @link based on substr(): http://www.zend.com/manual/function.substr.php 22 * @author Mike Kerr <tiki.kerrnel at kerris dot com> 23 * @param string 24 * @param position: start position of substring (default=0, negative starts N from end) 25 * @param length: length of substring (default=to end of string; negative=left N from end) 26 * @return string 27 */ 28function smarty_modifier_substring($string, $position = 0, $length = null) 29{ 30 31 if ($length == null) { 32 return substr($string, $position); 33 } else { 34 return substr($string, $position, $length); 35 } 36} 37