spacify
插空

Parameter PositionTypeRequiredDefaultDescription
1stringNoone space This what gets inserted between each character of the variable.
将在两个字符之间插入的字符

spacify is a way to insert a space between every character of a variable. You can optionally pass a different character (or string) to insert.

插空(不知道这个词是什么意思,顾名思义了^^)是一种在字符串的每个字符之间插入空格或者其他的字符(串).

Example 5-17. spacify
例 5-17.插空

index.php:



$smarty = new Smarty;

$smarty->assign('articleTitle', 'Something Went Wrong in Jet Crash, Experts Say.');

$smarty->display('index.tpl');



index.tpl:



{$articleTitle}

{$articleTitle|spacify}

{$articleTitle|spacify:"^^"}



OUTPUT:



Something Went Wrong in Jet Crash, Experts Say.

S o m e t h i n g   W e n t   W r o n g   i n   J e t   C r a s h ,   E x p e r t s   S a y .

S^^o^^m^^e^^t^^h^^i^^n^^g^^ ^^W^^e^^n^^t^^ ^^W^^r^^o^^n^^g^^ ^^i^^n^^ ^^J^^e^^t^^ ^^C^^r^^a^^s^^h^^,^^ ^^E^^x^^p^^e^^r^^t^^s^^ ^^S^^a^^y^^.