php正则替换解决思路

WBOY
Release: 2016-06-13 12:12:43
Original
942 people have browsed it

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个

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template