Home  >  Article  >  Backend Development  >  php正则替换解决思路

php正则替换解决思路

WBOY
WBOYOriginal
2016-06-13 12:12:43892browse

php正则替换
$array = array('aaa','bbbbbb','cccccc','ddddddddddd');
$str = 'abcdej{$array}jdijij';

$str = preg_replace("/^\{\$(.*?)\}$/i",'print_r(\\1);',$str);
print_r($str);

如何替换成 {print_r($array)}    正则怎么写??
还有 for while foreach 等正则该怎么写???
------解决思路----------------------
这是测试得来的,比如我的环境就得写3个

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn