Re: [SMARTY] Padding Strings

From: Date: Sat, 13 Mar 2004 10:16:28 +0000
Subject: Re: [SMARTY] Padding Strings
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-11115@lists.php.net to get a copy of this message
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} should work. - david

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