Posizione del Parametro | Tipo | Obbligatorio | Default | Descrizione |
---|---|---|---|---|
1 | stringa | Sì | nessuno | E' 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().
Example 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
Comments