|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
jotango Smarty Rookie
Joined: 20 Apr 2005 Posts: 13
|
Posted: Wed Dec 13, 2006 12:41 pm Post subject: New Smarty function: substring (code included) |
|
|
Hello,
we needed substr in our application, so we built a 1:1 wrapper for the PHP substr function. Perhaps its useful for someone else.
Best regards
Jan
Code: | <?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
* @author Manuel Polacek / Hitflip
*/
/**
* Smarty regex_replace modifier plugin
*
* Type: modifier<br>
* Name: substring
* Purpose: substring like in php
* @param string
* @return string
*/
function smarty_modifier_substring($sString, $dFirst = 0, $dLast = 0) {
if($dLast == 0) {
return substr($sString, $dFirst);
} else {
return substr($sString, $dFirst, $dLast);
}
}
?> | [/code] |
|
Back to top |
|
TGKnIght Smarty Junkie
Joined: 07 Sep 2005 Posts: 580 Location: Philadelphia, PA
|
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|