Home > Backend Development > PHP Tutorial > php正则表达式婚配疑问

php正则表达式婚配疑问

WBOY
Release: 2016-06-13 13:15:38
Original
778 people have browsed it

php正则表达式匹配疑问。

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->$data = "<meta http-equiv="Content-Type" content="text/html; charset=utf-8">aaa/r/naaaaaaaaaaaa"; 

preg_match_all('/<meta>]*charset=([a-zA-Z0-9]*[\-]*[0-9]*)/', $data, $meta);
var_dump($meta);
Copy after login

为什么打印出来是:
array
  0 => 
  array
  0 => string '   1 => 
  array
  0 => string 'utf-8' (length=4)

第二个匹配到utf-8是怎么匹配的?
不是只能匹配第一个吗?

------解决方案--------------------
探讨
PHP code
$data = "aaa/r/naaaaaaaaaaaa";

preg_match_all('/]*charset=([a-zA-Z0-9]*[\-]*[0-9]*)/', $data, $meta);
var_dump($……
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