spacify
パラメータの位置 | 型? | 必須 | デフォルト | 概要 |
1 | string? | No | one space | 変数の各キャラクタ間に挿入される要素 |
変数の各キャラクタ間にスペースを挿入します。
第1パラメータには、挿入するキャラクタ(または文字列)を渡す事ができます。
第1パラメータには、挿入するキャラクタ(または文字列)を渡す事ができます。
例 5-16. spacify
<?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:"^^"}
出力 :
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^^.