易截截图软件、单文件、免安装、纯绿色、仅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中创建数组

原文链接:http://www.phpdo.net/index.php/20100409/54.html
如何在PHP中创建数组呢?
在PHP中使用array函数来创建一个数组,它允许一定数量用逗号key=>value参数。Key可以是integer或者string类型,value可以是任何值。
例如:
 <?php
 $array = array(“php1″=>”phpdo”, ......

php Mod rewrite test

In the directory where you plan to install Elgg, do the following:
Create the file .htaccess and add these two lines
RewriteEngine on
RewriteRule ^testing.php$ modrewrite.php
This tells the webserver to load modrewrite.php when testing.php is
requested.
In order to get this test to work on ......

[转]用PHP的ob_start();控制您的浏览器cache!


Output Control
函数可以让你自由控制脚本中数据的输出。它非常地有用,特别是对于:当你想在数据已经输出后,再输出文件头的情况。输出控制函数不对使用
header()

setcookie(),
发送的文件头信息产生影响
,
只对那些类似于
echo()

PHP
代码的数据块有作用。
我们先举一个简单的例子,让大家对 ......

[转]PHP分页显示制作详细讲解


<!--
/* 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:"\@宋体" ......

PHP+DOM创建XML文件

创建文档类型声明
一般而言,XML声明放在文档顶部。在PHP中声明十分简单:只需实例化一个DOM文档类的对象并赋予它一个版本号。查看程序清单A:
程序清单 A
<?php
// create doctype
$dom = new DOMDocument("1.0");
// display document in browser as plain text
// display document in browser as plain text ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号