php 截取utf 8字符串
找了很多这样的函数,还是觉的这个最好了
$a = 'aadfdsf夺顶替一枯基22245顶替sdffh压下';
/**
* 截取utf-8字符
* @param string $string
* @param int$length
*
* return string
*/
function cutstr($string, $length) {
preg_match_all("/./u", $string, $info);
$i = 0;
$str = '';
foreach($info[0] as $item){
if(strlen($item) == 3){
$i+=2;
}else{
$i++;
}
$str .= $item;
if($i>=$length)break;
}
return $str;
}
echo cutstr($a, 10); //-> aadfdsf夺顶
相关文档:
在网上看了很多关于windows2003+iis6+php+mysql 服务器配置的文章,大体上都是互相抄袭,不过一些公共的信息还是很正确的,但是针对一些特别的机器或者因为个人不同的配置总不能按照文章的内容操作成功,下面说一种较为简单的操作方法,步骤如下:
1.iis安装(略)
2.下载AppServ并安装
3.在c:\建php5文件夹,然后再php5 ......
<?php
* xCopy("feiy","feiy2",1):拷贝feiy下的文件到 feiy2,推销员的一天,包括子目录
*参数说明:
* $destination:目的目录名
......
如下php代码
<?php
$type='a';
$target='type';
$a=array(1,2,3);
a($target);
function a($type)
{
global $$type;
var_dump($$type);
}
?>
预计输出的是string(1)”a”
可是结果是
Notice: Undefined variable: a in D:\web\global.php on ......
<p>04级新生名单</p>
<table border="1" width="80%" cellpadding="0">
<tr>
<td width="10%" align="center">Id</td>
<td width="20%" align="center">Name</td>
<td width="10%" align="center">Age</td>
<td width="10%" align="cent ......
$pagesize=10; //设置每一页显示的记录数
$c("localhost","root",""); //连接数据库
$rs=mysql_query("select count(*) from tb_product",$conn); //取得记录总数$rs
$myrow = mysql_fetch_array($rs);
$numrows=$myrow[0];
Ɍ ......