良い一日。
カスタム スクリプト用にローカリゼーション システムで SprintF 関数を使用していますが、多くのコードを節約できる列挙値も使用したいと考えています。
今、私はそうしています
$string = 'Some localisation string with %s and %s variables.';
$qwe = sprintf($string,'xxx', 'yyy'); //returns: Some localisation string with xxx and yyy variables.
単純な値には適していますが、列挙可能なものを使用したい状況がたくさんあります。
だから、私はこのようなものが欲しいです
$string = 'Some string %{qwe,zxc,ddd,yyy} blah blah';
$qwe = someFunction($string,1); //would return: Some string zxc blah blah
$qwe = someFunction($string,3); //would return: Some string yyy blah blah
出来ますか?使用できる組み込み関数はありますか? それとも、自分で実装する必要がありますか? もしそうなら、おそらくいくつかのソリューションまたはライブラリがすでに存在しますか?
PS - テンプレート エンジンの使用を勧めないでください。この特定の機能だけが必要です。