Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: [SMARTY] Padding Strings
> What is the easiest way to pad a string in smarty?

Just embed the smarty-var in the string:
--{$myVar}--

works also in loops  ;)

- david

Report this thread to moderator Post Follow-up to this message
Old Post
David Förster
03-19-04 06:29 PM


Re: [SMARTY] Padding Strings
Sorry, I didn't explain it well enough, because I don't know what the strin=
g
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 =3D "Alien";
echo str_pad($input, 10, "_", STR_PAD_BOTH);  // produces "__Alien___"
?>

Jake

On 13/3/04 9:37, "David F=F6rster" <david@dfoerster.de> wrote:
 
>=20
> Just embed the smarty-var in the string:
> --{$myVar}--
>=20
> works also in loops  ;)
>=20
> - david

Report this thread to moderator Post Follow-up to this message
Old Post
Jake Stride
03-19-04 06:29 PM


Re: [SMARTY] Padding Strings
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
& #123;$myVar|str_pad:10:'_':STR_PAD_BOTH}

should work.

- david

Report this thread to moderator Post Follow-up to this message
Old Post
David Förster
03-19-04 06:29 PM


Re: [SMARTY] Padding Strings
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:
> 
>
> If you're security settings are not too strict, you can use any php
> function as a modifier, so
> & #123;$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

Report this thread to moderator Post Follow-up to this message
Old Post
Messju Mohr
03-19-04 06:29 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP Smarty Templates archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 11:06 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.