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

PHP截取固定长度字符串函数

<?php   
  
function toFixLen($str,$len){ //固定长度字符串的截取   
  
    if($len>=strlen($str)||!$len) return $str;   
  
    $len-=3;   
  
    $tempstr1 = substr($str,0,$len); //截取字符串   
  
    $tempstr2 = preg_replace('/([\x81-\xff]+)$/ms','',$tempstr1,1); //去掉结尾的连续汉字字符   
  
    if(!is_int((strlen($tempstr1)-strlen($tempstr2))/2)){ //去掉的字符为奇数?   
  
        $tempstr1 = substr($str,0,$len-1);   
  
    }   
  
    return $tempstr1."…";   
  
}   
  
?>


相关文档:

php 不用COM 生成excel文件


 
用php生成excel文件
<?
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=test.xls");
echo "test1/t";
echo "test2/t/n";
echo "test1/t";
echo "test2/t/n";
echo "test1/t";
echo "test2/t/n";
echo "test1/t";
echo "test2/t/n";
echo "test1/t";
e ......

PHP中的MYSQL常用函数总结

PHP中的MYSQL常用函数总结
1、mysql_connect()-建立数据库连接
格式:
    resource mysql_connect([string hostname [:port] [:/path/to/socket] [, string username] [, string password]])
例:
    $conn = @mysql_connect("localhost", "username", "password") or dir( ......

PHP安装问题:编译安装php5.2.0时出错解决方案

编译安装php5.2.0时出错解决方案
1.错误信息...................如下
checking for mcrypt support... no
checking for mhash support... no
checking whether to include mime_magic support... no
checking for MING support... no
checking for mSQL support... no
checking for MSSQL support via FreeTDS ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号