Home  >  Article  >  php教程  >  正值表达式匹配html标签的属性值,表达式属性值

正值表达式匹配html标签的属性值,表达式属性值

WBOY
WBOYOriginal
2016-06-13 08:45:42768browse

正值表达式匹配html标签的属性值,表达式属性值

  今天由于工作的需求,需要获取html标签的属性值,立即想到了正则表达式,标签如下:




需要获取标签的cx、cy的属性值,想了一会写出了一个:

$circle是上面的circle标签的内容

preg_match_all('/]*?cx\s*=\s*(\'|\")(.*?)\\1[^>]*?cy\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $circle, $arr);

var_dump($arr);

$arr[2]是cx的值 ,$arr[4]是cy的值.



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