归档于 ‘php’ 分类

05
5

网络改变世界

每一样发明都在深刻影响着我们这个世界,改变我们的生活工作习惯。
车的发明,使人的活动空间发生了改变,以前从广东到北京走路骑马要一个月,现在京广铁路才1天不到;城际列车,使整个珠三角成为人们的生活圈,工资在深圳,居住在珠海不是梦想。
在九十年代,比尔盖茨说,网络将改变人的生活方式,当时没有什么感觉,现在回想起来,确实如此,网络重组了世界运转的模式,影响了人类获取资讯和交流的方式,例如现在的猪流感,因为各国资讯的公开,猪流感就像在照妖镜前面一样无所遁形,因此也不可能像过去那样大规模流行起来了。
网络,在我们生活中将越来越重要,而我们有幸生活在这个网络刚起步的年代。

02
4

正则去除所有链接,然指定链接不去除[z]

方法二三较为简单.推荐
问题提问地址: www.phpchina.com/bbs/thread-91930-1-1.html
方法一:
<?php
/**
* 替换非指定的链接
*
* @param string $str                 // 要过滤的文本
* @param string $top_level_domain    // 一级域名,但不包含www 如[url=http://www.google.com]http://www.google.com[/url] 输入google.com
* @return string $str
*/
function replace_not_appoint_url($text, $top_level_domain) {
$top_level_domain_regex = str_replace(‘.’, ‘\.’, $top_level_domain);
//$parten1 = ‘/<a(.*?)href=(”|\’)?http:\/\/(.*?)\.?google\.com\/?(.*?)(”|\’)?(.*?)>(.+?)<\/a>/i’;
$parten1 = ‘/<a(.*?)href=(”|\’)?http:\/\/(.*?)\.?’.$top_level_domain_regex.‘\/?(.*?)(”|\’)?(.*?)>(.*?)<\/a>/i’;
//$parten2 = ‘<a\\1#Mref#=”http://\\3.google.com/\\4″\\5>\\6</a>’;
$parten2 = ‘<a\\1#Mref#=\\2http://\\3.’.$top_level_domain.‘/\\4\\5\\6>\\7</a>’;
$parten3= ‘/<a.*?href.*?>(.*?)<\/a>/i’;
$text = preg_replace($parten1, $parten2, $text);
$text = preg_replace($parten3, ‘\\1′, $text);
$text = [...]