我有这些变量:
$summary="The problem with field2 is field13. The fix will be field7"
$_POST['field2']='thiscomputer';
$_POST['field7']='thishotfix';
$_POST['field13']='thisapplication';
我正在尝试制作一个preg_replace(),它将在字符串中找到/ field [0-9] /并将其替换为$ _POST数组中的值。但是我一直很简短。也许preg_replace()是在此实例中使用的错误函数。我正在尝试替换50+ str_replace的旧列表
感谢您的帮助,可以为我指明正确的方向
那一行str_replace
代替preg_replace
呢?您可能需要修复一些间距,可以通过数组值解决
echo str_replace(array_keys($_POST),array_values($_POST),$summary);
输出:
The problem with thiscomputer is thisapplication. The fix will be thishotfix
工作演示: https : //3v4l.org/quYVO
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句