php怎么替换title、keywords、description中的内容? phphtml正则区配 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $str='<title>测试</title><meta name="keywords" content="测试"><meta name="description" content="测试">';$str=preg_replace('/(<title>)[^<]+?(<\/title>)/i',"$1替换$2",$str);$str=preg_replace('/(name="keywords"\s*content)="[^"]+?"/i',"$1='替换'",$str);$str=preg_replace('/(name="description"\s*content)="[^"]+?"/i',"$1='替换'",$str);echo $str;/*输出(查看元素)<title>替换</title><meta name="keywords" content="替换"><meta name="description" content="替换">*/ $content = <<<TXT<!DOCTYPE html><head><meta charset="UTF-8"><title>NM+「潮 + 互動」全方位媒體平台</title><meta name="keywords" content="NM+,潮 ,互動,全方位媒體平台" /><meta name="description" content="NM+「潮 + 互動」全方位媒體平台" /></head><body></body></html>TXT;$content = preg_replace('/(<title>)(.*?)(<\/title>)/i', "$1替換的title$3", $content);$content = preg_replace('/(name="keywords" content=")(.*?)(")/i', "$1替換的keywords$3", $content);$content = preg_replace('/(name="description" content=")(.*?)(")/i', "$1替換的description$3", $content);echo $content; 请教一个jquery.ajax的问题。 PHP在登录系统中,不管输入任何登录子页网址,都必须先登陆主页 php中"./"和"../"有啥区别? 自定义函数怎么调用? 得空的进来,讨论一下XML、Web Service. 使用QQ登录!急急急!!!! 请问PHP和ASP哪个比较好一点? linux中的上传文件权限不足,怎么办? phpadmin执行sql语言时间如何改变? 紧急求教 求助 PHP发邮件问题 求大神看看这个路径怎么回事?
$str='<title>测试</title>
<meta name="keywords" content="测试">
<meta name="description" content="测试">';$str=preg_replace('/(<title>)[^<]+?(<\/title>)/i',"$1替换$2",$str);
$str=preg_replace('/(name="keywords"\s*content)="[^"]+?"/i',"$1='替换'",$str);
$str=preg_replace('/(name="description"\s*content)="[^"]+?"/i',"$1='替换'",$str);
echo $str;
/*输出(查看元素)
<title>替换</title>
<meta name="keywords" content="替换">
<meta name="description" content="替换">
*/
$content = <<<TXT
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title>NM+「潮 + 互動」全方位媒體平台</title>
<meta name="keywords" content="NM+,潮 ,互動,全方位媒體平台" />
<meta name="description" content="NM+「潮 + 互動」全方位媒體平台" />
</head>
<body>
</body>
</html>
TXT;$content = preg_replace('/(<title>)(.*?)(<\/title>)/i', "$1替換的title$3", $content);
$content = preg_replace('/(name="keywords" content=")(.*?)(")/i', "$1替換的keywords$3", $content);
$content = preg_replace('/(name="description" content=")(.*?)(")/i', "$1替換的description$3", $content);echo $content;