Re: [SMARTY] Padding Strings

From: Date: Sat, 13 Mar 2004 13:03:18 +0000
Subject: Re: [SMARTY] Padding Strings
References: 1 2 3  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-11116@lists.php.net to get a copy of this message
On Sat, Mar 13, 2004 at 12:16:28PM +0200, David Förster wrote: > On Sat, 13 Mar 2004 10:00:46 +0000 > Jake Stride <jas@dcs.warwick.ac.uk> wrote: > > > Sorry, I didn't explain it well enough, because I don't know what the > > string will be as it comes from a db, so it could be: > > > > ---ab--- > > > > I basically want to pad a string left and right, but dynamically, ie > > the same as: > > > > <?php > > $input = "Alien"; > > echo str_pad($input, 10, "_", STR_PAD_BOTH); // produces "__Alien___" > > ?> > > If you're security settings are not too strict, you can use any php > function as a modifier, so > {$myVar|str_pad:10:'_':STR_PAD_BOTH} (just a little addition) to get the const straight it's: {$myVar|str_pad:10:'_':$smarty.const.STR_PAD_BOTH} greetings messju > should work. > > - david > > -- > Smarty General Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.smarty.general (#11116) next »