21,886
社区成员
发帖
与我相关
我的任务
分享
$a = array(1,2,3);
$b = 'test %s and test %o and %s ';
echo str_replace('&&&&','%',vsprintf( str_replace('%','%s&&&&',$b), $a));
$a = array(111,222,333);
$b = 'test %s and test %o and %s ';
$b = explode( '%', $b );
foreach( $b as $key => $var )
{
if( !empty( $a[$key] ) )
{
$b[$key] = $var.$a[$key];
}
}
$b = implode( "%", $b );
echo $b;