Menu Close

切分文字

想在sql中进行模糊匹配查询, 类似于将”一二三abc” 切分成 “一%二%三%a%b%c”.

function split_str($str) {
    $temp = '';
    $num = strlen($str);
    for ($i = 0; $i < $num; $i++) {
        if (mb_detect_encoding($str[$i]) === false) {
            $temp. = $str[$i];
        } else {
            $temp. = '%'.$str[$i];
        }
    }
    return $temp;
}

发表评论

邮箱地址不会被公开。 必填项已用*标注

沪ICP备14006760号-2