易截截图软件、单文件、免安装、纯绿色、仅160KB

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];


相关文档:

PHP autoload机制详解

(1) autoload机制概述
在使用PHP的OO模式开发系统时,通常大家习惯上将每个类的实现都存放在一个单独的文件里,这样会很容易实现对类进行复用,同时将来维护时也很便利。这也是OO设计的基本思想之一。在PHP5之前,如果需要使用一个类,只需要直接使用include/require将其包含进来即可。下面是一个实际的例子:
CODE:
/* ......

[转]PHP中str_replace函数的详解


在实际的程序开发中,执行字符串替换操作是一件非常经常的事,对
str_replace
函数的实用也会非常频繁。
     
这段时间在看《
PHP

MySQL Web
开发》一书看到
str_replace
讲解,一段小提示写到:可以为
str_replace
的三个都使用数组传入,但讲解比较简单,于是决定自己的试验 ......

HTML 个人简历源码

<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>易水 ......

CentOS通过yum升级php到5.2.9版本的方法

CentOS的php版本默认为5.1.6,然后在5.2.9版本之前的的php都存在一个漏洞,但是目前网上很多地方都无法使用yum update php*升级到5.2.9,比较常见的是升级到5.2.6版本的,经过搜索国外资料,现在终于找到一种升级CentOS的php到5.2.9的方法。
运行下面命令:
# wget http://download.fedora.redhat.com/pub/epel/5/i386/ep ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号