实现函数template()函数
template('hello ${1}, ${2} is the best ${3}',['world','javascript','language']);
//输出结果
'hello world, javascript is the best language'
function template(str,array){
}
想到用正则表达式提取,但不知道怎么替换到原来的字符串?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
使用正则表达式进行匹配,如果配置位置对应的索引在数组中没有给出则以?替代