Re: [SMARTY] String padding modifier
| From: | Roman Neuhauser | Date: | Fri, 28 Jun 2002 09:23:28 +0000 |
| Subject: | Re: [SMARTY] String padding modifier | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-5085@lists.php.net to get a copy of this message | ||
> From: "Francesco Cipriani" <f.cipriani@inwind.it>
> To: "smarty-general@lists.php.net" <smarty-general@lists.php.net>
> Date: Thu, 27 Jun 2002 02:52:14 +0200 (CDT)
> Subject: [SMARTY] String padding modifier
>
> Hi all,
> I'm looking for a string padding modifier, which, given a string
> of size s, a length l, and a char c would add l-s chars of type c
> to the string
> Is there something like this around?
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: modifier
* Name: pad
* Purpose: right-pad a string of text to a given length using
* a given character
* -------------------------------------------------------------
*/
function smarty_modifier_pad($input,$pad_length,$pad_string=" ")
{
return str_pad($input,$pad_length,$pad_string);
}
add more logic to allow for left- or bothsides- padding.
--
FreeBSD 4.6-STABLE
11:22AM up 4 days, 8:22, 9 users, load averages: 0.03, 0.05, 0.01