CodeIgniter字符串截取

V层中加入:

$this->load->helper('sub_string');

使用:

$value){?>

一下文件保存为:sub_string_helper.php,放入helper中即可

 127) {
                $i ++;
                if ($i < $len) {
                    $new_str [] = substr ( $str, 0, 3 );
                    $str = substr ( $str, 3 );
                }
            } else {
                $new_str [] = substr ( $str, 0, 1 );
                $str = substr ( $str, 1 );
            }
        }
        return join ( $new_str );
    }else{
        return $str;
    }
}