php匹配html

html-css017

php匹配html,第1张

<tr>

<td width="3%" height="30" align="center" style="border-bottom:1px #cccccc dotted">·</td>

<td width="81%" style="border-bottom:1px #cccccc dotted" >

<?php //代码1?> <a href="<?php //代码2?>" target="_blank" title="<?php //代码3?>"><?php //代码4?></a></td>

<td width="16%" align="center" style="border-bottom:1px #cccccc dotted"><font color="#666666">

<?php //代码5?> </font></td>

</tr>

你可以详细说下你的问题!然后我进一步回答!

<?php

$str = '<a id="btlist10" st="1" ditem="true" class="item multi-lines with-avatar" ftios="1" ck="TlRZNFlUSTRNakk9" 

ft="1" data="我想匹配的属性值" ix="10" analytical="false" s1="我想匹配的属性值2" 

jxd1="0781C99068C8FEBF" jxd2="69A2D6435ABEAF87817A812290560AB3" onclick="openmenu($(this))">'

$fun = function($str,$key){

    $str=preg_replace("/[\s\S]*\s".$key."[=\"\']+([^\"\']*)[\"\'][\s\S]*/","$1",$str)

    return $str

}

$data = $fun($str, "data")

echo $data

echo "\n"

$s1 = $fun($str, "s1")

echo $s1

echo "\n"

$other = $fun($str, "ck")

echo $other

echo "\n"

$other = $fun($str, "onclick")

echo $other

?>