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生成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 ......
经过2个星期的艰苦奋斗,终于小有成就。详细的流程我之前也有说过。所以不再提出。直接上代码,希望对大家有所帮助。
1.LOGIN.php
<?php
include_once"conn2.php";
$uname=$_POST['uname'];//接收传过来的用户名
$upwd=$_POST['upwd'];//接收传过来的密码并md5()
$sql="SELECT * from pv_master WH ......
getenv() 取得系统的环境变量(预定义变量)
$spager=getenv('SERVER_NAME');
“PHP_SELF”
当前正在执行脚本的文件名,与 document root 相关。举例来说,在 URL 地址为 [url]http://example.com/test.php/foo.bar[/url] 的脚本中使用 $_SERVER['PHP_SELF'] 将会得到 /test.php/foo.bar 这个结 ......
岗位职责
1、协助系统架构设计师进行系统架构设计工作;
2、承担Web应用核心模块的设计/实现工作;
3、承担主要开发工作,对代码质量及进度负责;
4、进行关键技术验证以及技术选型工作;
5、和产品经理沟通并确定产品开发需求;
岗位要求
1、具有互联网领域相关项目开发工作经验,对互联网业务以及技术有相 ......
原帖地址:http://www.phpma.com/english/20071215/640.html
Description
array explode
( string separator, string string [, int limit])phpma.com
Returns an array of strings, each of which is a substring of string
formed by splitting it on boundaries formed by the string separator
. If limit
is ......