phpÕýÔòȡǶÌ×html±êÇ©
<?php
$s = <<<html
<html>
<head>
<title>nested tag test</title>
<mce:script type="text/javascript"><!--
alert('fdsafdasfasd');
// --></mce:script>
</head>
<body>
<div id=0>
<div id=1><img name="img1" id="img1" src=""/>
<div id=2><img name="img2" id="img2" src=""/>
<div id=3><img name="img3" id="img3" src=""/>
</div>
</div>
</div>
</div>
</body>
</html>
html;
$pattern = "/(".
"<\!\w+(?:\s+[^>]*?)+\s*>|".
"<\w+(?:\s+\w+(?:\s*=\s*(?:\"[^\"]*\"|'[^']*'|[^\"'>\s]+))?)*\s*\/?>|".
"<\/\w+\s*>|".
"<\!--[^-]*-->".
")/";
preg_match_all($pattern, $s, $aMatches, PREG_OFFSET_CAPTURE);
function getMatchTags($s, $arr) {
$sMatchClose = '';
$arrClose = array();
$arrReturn = array();
for($i=0; $i<count($arr); $i++) {
$iCount = 0;
if (preg_match("/<[^>\s*]*/", $arr[$i][0], $aMatchOpen)) {
$sMatchClose = '</' . substr($aMatchOpen[0], 1) . '>';
for($j=$i-1; $j<count($arr); $j++) {
if (!(stripos($arr[$j][0], $aMatchOpen[0]) === false)) {
$iCount ++;
$flag = 1;
}
if (!(stripos($arr[$j][0], $sMatchClose) === false)) {
$iCount --;
$flag = 1;
if($iCount == 0 && $flag == 1) {
$arrClose[] = $arr[$i];
$arrClose[] = $arr[$j];
}
}
}
}
}
$k=0;
for($i=0; $i<count($arrClose); $i+=2) {
$arrReturn[$k][0] = $arrClose[$i];
$arrReturn[$k][1] = $arrClose[$i+1];
Ïà¹ØÎĵµ£º
ÔÎÄÁ´½Ó£ºhttp://www.phpdo.net/index.php/20100409/54.html
ÈçºÎÔÚPHPÖд´½¨Êý×éÄØ£¿
ÔÚPHPÖÐʹÓÃarrayº¯ÊýÀ´´´½¨Ò»¸öÊý×飬ËüÔÊÐíÒ»¶¨ÊýÁ¿ÓöººÅkey=>value²ÎÊý¡£Key¿ÉÒÔÊÇinteger»òÕßstringÀàÐÍ£¬value¿ÉÒÔÊÇÈκÎÖµ¡£
ÀýÈ磺
<?php
$array = array(“php1″=>”phpdo”, ......
ÔÚʵ¼ÊµÄ³ÌÐò¿ª·¢ÖУ¬Ö´ÐÐ×Ö·û´®Ìæ»»²Ù×÷ÊÇÒ»¼þ·Ç³£¾³£µÄÊ£¬¶Ô
str_replace
º¯ÊýµÄʵÓÃÒ²»á·Ç³£Æµ·±¡£
Õâ¶Îʱ¼äÔÚ¿´¡¶
PHP
ºÍ
MySQL Web
¿ª·¢¡·Ò»Êé¿´µ½
str_replace
½²½â£¬Ò»¶ÎСÌáʾдµ½£º¿ÉÒÔΪ
str_replace
µÄÈý¸ö¶¼Ê¹ÓÃÊý×é´«È룬µ«½²½â±È½Ï¼òµ¥£¬ÓÚÊǾö¶¨×Ô¼ºµÄÊÔÑé ......
<!--
/* Font Definitions */
@font-face
{font-family:ËÎÌå;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"\@ËÎÌå" ......
<html>
<meta http-equiv="Content-Type" content="text/html; charset=GBK" />
<head>
<title>Ò×Ë®º®µÄ¸öÈ˼òÀú</title>
</head>
<body bgcolor="#CCFFCC" lang=ZH-CN link=blue vlink=blue style='tab-interval:21.0pt'topmargin=4>
<center><h1>Ò×Ë® ......
ÈçºÎÏòHTML 5¹ý¶É£¿
¡¡¡¡Web¿ª·¢ÉçÇøµÄ²»ÉÙÈËÈÏΪתÏòHTML 5Òª½÷É÷¡£±ÈÈ磬ËäȻ΢Èí¼Æ»®ÔÚIE9ÖÐÖ§³ÖHTML 5£¬µ«Õâ¼ÒÈí¼þÒµ¾Þ뢶ÔÓÚÔÚHTML 5»¹Ã»ÓÐÕýʽ³ÉΪ±ê׼֮ǰ֧³ÖËüÐÄ´æÒÉÂÇ¡£Î¢ÈíWindowsÊÂÒµ²¿×ܲÃSteven Sinofsky×î½ü½ÓÊܲɷÃʱ±íʾ£º“ÏÈ˵×Ô¼º»ùÓÚ±ê×¼£¬µ«ËæºóÓÖ˵ÄãÊÇ×î¼æÈÝHTML 5µÄä¯ÀÀÆ÷£¬ÕâÖÖ×ö·¨²»Ã÷ÖÇ£ ......