分享

php实现seo伪原创,同义词替换

 yliu277 2016-01-16
<?php
echo strtr_words('这里是需要转换的文字');
function strtr_words($str)
{
    $words=array();
    $content = file_get_contents('word.txt');//词库
    $content = str_replace( '\r', '',$content); //去掉换行符(以便兼容Linux主机)
    $content = preg_split('/\n/', $content, -1, PREG_SPLIT_NO_EMPTY);//\n分割字符
        foreach($content as $k=>$v)
        {
            if($k!=0)
            {
                $str_data = explode('→',$v);//关键词分割符
                $words =array('$str_data[0]'=>'$str_data[1]');
            }
        }
    return strtr($str,$words);//返回结果
}
?>

词库可以去百度搜索下载

格式为

好看→美丽

难过→伤心

我的影视站:好看影视网

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多