易截截图软件、单文件、免安装、纯绿色、仅160KB

php截取中文字符串


1. 截取GB2312中文字符串
<?php
< ?php 
//截取中文字符串
function mysubstr($str, $start, $len) {
    $tmpstr = "";
    $strlen = $start + $len;
    for($i = 0; $i < $strlen; $i++) {
        if(ord(substr($str, $i, 1)) > 0xa0) {
            $tmpstr .= substr($str, $i, 2);
            $i++;
        } else
            $tmpstr .= substr($str, $i, 1);
    }
    return $tmpstr;
}
?>
2. 截取utf8编码的多字节字符串
<?php
< ?php
//截取utf8字符串
function utf8Substr($str, $from, $len)
{
    return preg_replace('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$from.'}'.
                       '((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$len.'}).*#s',
                       '$1',$str);
}
?>
3. UTF-8、GB2312都支持的汉字截取函数
<?php
< ?php
/* 
Utf-8、gb2312都支持的汉字截取函数 
cut_str(字符串, 截取长度, 开始长度, 编码); 
编码默认为 utf-8 
开始长度默认为 0 
*/ 
 
function cut_str($string, $sublen, $start = 0, $code = 'UTF-8') 

    if($code == 'UTF-8') 
    { 
        $pa = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xef][\x80-\xbf][\x80-\xbf]|\xf0[\x90-\xbf][\x80-\xbf][\x80-\xbf]|[\xf1-\xf7][\x80-\xbf][\x80-\xbf][\x80-\xbf]/"; 
       &nb


相关文档:

使用Flex和PHP创建自己的视频应用


来源:蓝色理想 作者:Dreamer 2007年10月16日 14:50 网友评论:0条 点击:
2737
Dreamer的Blog:www.zhuoqun.net/
英文原文:Creating MyTube with Flex and PHP
原文地址:
http://www.onlamp.com/pub/a/php/2007/05/24/creating-mytube-with-flex-and-php.html
原文作者:Jack Herrington
随着宽带的普及、 ......

Dompdf for PHP & Replace Url to link

If you want to put some big table in the pdf file, you may got the layout messy. One way to solve the problem is to change the paper size.  In "includes/cpdf_adapter.cls.php", Change the size you used in the array to whatever you want.
One tip: Replace Url into Clickable link.
$tex ......

php4 xml 生成类

由于 在php4的环境下. 都没找到自动生成的函数. 所以自己改写了一个别人些的类. 用来自动生成xml 文件.
<?php
/*
*** 功能 : php4自動生成xml 文件類
*** @ edit: zxwo0o
*** @ time: 2009-9-22
*/
class php4xml{
var $version; //版本號
var $start; ......

php支持memcache

memcache个人理解主要是用来管理内存的,php和memcache结合就可以使php吧一些数据保存在memcache管理的内存里,方便管理,也快,还支持多台服务器共享数据,废话不多说. 分为linux和windows 1)linux和类Unix可以从以下地址下载memcached和libevent,由于安装memcache需要libevent支持,所以需要先安装libevent memcached官方 ......

PHP中str_replace函数的详解

     在实际的程序开发中,执行字符串替换操作是一件非常经常的事,对str_replace函数的实用也会非常频繁。
      这段时间在看《PHP和MySQL Web开发》一书看到str_replace讲解,一段小提示写到:可以为str_replace的三个都使用数组传入,但讲解比较简单,于是决定自己 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号