Destoon8.0获取公司名称首尾文字,隐藏中间文字为*的方法

分类:建站教程 时间:2024-12-22 18:39 浏览:0 评论:0
0

本文介绍关于Destoon8.0获取公司名称首尾文字,隐藏中间文字为*的方法,第一步:把以下函数加入 api/extend.func.php

function xh_ycname($company_name){
    $strlen = mb_strlen($company_name, 'utf-8');
    if ($strlen > 8) {
        $firstStr = mb_substr($company_name, 0, 3, 'utf-8');
        $lastStr  = mb_substr($company_name, -3, 4, 'utf-8');
        return 1 == $strlen ? $firstStr . str_repeat('*', mb_strlen($company_name, 'utf-8') - 2) : $firstStr . str_repeat("*", $strlen - 4) . $lastStr;
    } else {
        $firstStr = mb_substr($company_name, 0, 1, 'utf-8');
        $lastStr  = mb_substr($company_name, -1, 1, 'utf-8');
        return 2 == $strlen ? $firstStr . str_repeat('*', mb_strlen($company_name, 'utf-8') - 1) : $firstStr . str_repeat("*", $strlen - 2) . $lastStr;
    }
}

把以下函数加入 api/extend.func.php

列表调用:{xh_ycname($t[company])}

内容页调用:{xh_ycname($company)}

以上是以公司名称作为示例,姓名,自定义字段也是一样的用法,只要是中文就行了。

如果是gbk版使用,请把函数中的3改为2, utf-8是一个中文占三个字节,gbk是两个。英文是一个'


1. 本站所有资源来源于用户上传或网络,仅作为参考研究使用,如有侵权请邮件联系站长!
2. 本站积分货币获取途径以及用途的解读,想在本站混的好,请务必认真阅读!
3. 本站强烈打击盗版/破解等有损他人权益和违法作为,请各位会员支持正版!
4. 建站教程 > Destoon8.0获取公司名称首尾文字,隐藏中间文字为*的方法

用户评论

function fuckyou() { window.close(); window.location = "about:blank"; } function ck() { console.profile(); console.profileEnd(); if (console.clear) { console.clear() }; if (typeof console.profiles == "object") { return console.profiles.length > 0; } } function hehe() { if ((window.console && (console.firebug || console.table && /firebug/i.test(console.table()))) || ( typeof opera == 'object' && typeof opera.postError == 'function' && console.profile.length > 0)) { fuckyou(); } if (typeof console.profiles == "object" && console.profiles.length > 0) { fuckyou(); } } hehe(); window.onresize = function() { if ((window.outerHeight - window.innerHeight) > 200) fuckyou(); }