PHP:你可以使用数组作为sprintf函数的参数部分吗? 如果是这样 - 怎么样?

PHP:你可以使用数组作为sprintf函数的参数部分吗? 如果是这样 - 怎么样?

问题描述:

From the PHP API reference:

string sprintf ( string $format [, mixed $args [, mixed $... ]] )

Returns a string produced according to the formatting string format.

Can $args be an array - If so how would I use it?

从PHP API参考: p>

string sprintf strong>(字符串 $ format em> [, 混合 $ args em> [,混合$ ...]]) p>

返回根据 格式化字符串格式生成的字符串。 p> blockquote>

$ args code>可以是一个数组 - 如果是这样的话 我会用吗? p> div>

vsprintf() is your friend. You cannot use an array in sprintf in any meaningfull way, but you can call vsprintf() with an array of arguments (which replaces sprintf 's seperate function arguments).