js 实现php中sprintf函数

2013-12-11 孤独求学人 JavaScript

js 实现php中sprintf函数,完成完美替换操作!

<script type="text/javascript">
//js 实现php sprintf
function sprintf(){
 var arg = arguments,
 str = arg[0] || '',
 i, n;
 for (i = 1, n = arg.length; i < n; i++) {
    str = str.replace(/%s/, arg[i]);
 }

阅读全文>>

标签: PHP js sprintf

评论(0) 浏览(2902)

Powered by emlog 豫ICP备15004178号-1