- 论坛徽章:
- 0
|
cat 1.txt
[ <a class="warn" href="sudokus.cn_98/www.sudokus.cn_98.html#Disk">Disk</a> <a href="sudokus.cn_98/www.sudokus.cn_98.html#Network">Network</a> <a href="sudokus.cn_98/www.sudokus.cn_98.html#Other">Other</a> <a class="warn" href="sudokus.cn_98/www.sudokus.cn_98.html#Processes">Processes</a> <a href="sudokus.cn_98/www.sudokus.cn_98.html#Sendmail">Sendmail</a> <a href="sudokus.cn_98/www.sudokus.cn_98.html#System">System</a> ]</li>
此文件为一行.其中红色的二段,如果有class="warn"字样.就显示后面的第一个锚点,如Disk和Processes
php实现的方法如何.寻找与之类似的SHELL写法
[root@u munin]# cat 1.php
<?php
$html=file_get_contents("1.txt");
preg_match_all("/warn[^>]+#(\w+)\">/",$html,$out);
//<a href="sudokus.cn_98/www.sudokus.cn_98.html#Other">
print_r($out);
?>
You have new mail in /var/spool/mail/root
[root@u munin]# php 1.php
Array
(
[0] => Array
(
[0] => warn" href="sudokus.cn_98/www.sudokus.cn_98.html#Disk">
[1] => warn" href="sudokus.cn_98/www.sudokus.cn_98.html#Processes">
)
[1] => Array
(
[0] => Disk
[1] => Processes
)
) |
|