本文目录一览:
php获取html标签内容
? php
$str = 'a href="/p/3729597758" title="【爱心反馈】四川色达县色达中学反馈贴" target="_blank" class="j_th_tit"【爱心反馈】四川色达县色达中学反馈贴/a';
preg_match_all('/href="(.*?) title="(.*?)"/is', $str, $arr);//正则匹配
print_r($arr);#打印匹配结果
PHP获取指定页面中整个标签内容
$s = "form action=\" method=\"post\" class=\"con\"input type='hidden' name='csrfmiddlewaretoken' value='FHkJrIUwZCjKGgug0T1Q2apkM7Oligng' /-php获取标签里的内容
label for=\"login\"";
$bq = 'input';//获取所有input标签内容
$rex = '#'.$bq.'.*?#i';
preg_match_all($rex, $s, $matches);
var_dump($matches);
php 正则表达式取标签内容怎么写?
代码如下:
?php
$str = 'dd id="kj_num"
span class="blueball_big"2/span
span class="blueball_big"6/span
span class="blueball_big"6/span
/dd';
$matches = array();
if (preg_match_all('/"blueball_big"\(\d+)\/span/', $str, $matches)) {
foreach ($matches[1] as $value) {
print($value . ' ');
}
}
?