Home > Backend Development > PHP Tutorial > PHP 正则 ${1} 解释解决方法

PHP 正则 ${1} 解释解决方法

WBOY
Release: 2016-06-13 10:23:20
Original
1800 people have browsed it

PHP 正则 ${1} 解释

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?php $string = 'aaaa3aaa6aaaa2aaaaaa0aaaaaa2aaa1a';$pattern=array('/(\d)/i');$replace=array('[${1}]');echo $string."<br/>";echo preg_replace($pattern, $replace, $string);?> 
Copy after login


替换前:aaaa3aaa6aaaa2aaaaaa0aaaaaa2aaa1a
替换后:aaaa[3]aaa[6]aaaa[2]aaaaaa[0]aaaaaa[2]aaa[1]a
怎么个原理法啊?那个${1}如何解释啊?

------解决方案--------------------
是pattern里第一个括号的意思。
------解决方案--------------------
第一个子模式。即第一组()号的内容。
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