smarty template engine
Friday, August 08, 2008  
download | documentation | faq | forum | mailing lists | changelog | contribs 


search for in the  


string_format

Posizione del ParametroTipoObbligatorioDefaultDescrizione
1stringanessunoE' il formato da usare. (sprintf)

Questo è un modo di formattare stringhe, ad esempio per i numeri decimali e altro. Utilizzare la sintassi della funzione PHP sprintf().

Esempio 5-17. string_format

<?php

$smarty 
= new Smarty;
$smarty->assign('number'23.5787446);
$smarty->display('index.tpl');

?>

Dove index.tpl è:

{$number}
{$number|string_format:"%.2f"}
{$number|string_format:"%d"}

Questo stamperà:

23.5787446
23.58
24



 

credits 

Smarty Copyright © 2002-2008
New Digital Group, Inc.

All rights reserved.