日期:2014-05-16 浏览次数:20571 次
$temp = '判断是否有中文';判断*****
//判断是否有中文
if(preg_match('/[\x81-\xfe][\x40-\xfe]/',$temp)){
mb_internal_encoding("gbk");
}else {
mb_internal_encoding("utf-8");
}
$len = mb_strlen($temp);
$t = '';
for($k=0; $k<$len; $k++){
if($k>1) {
$t .= '*';
}else {
$t .= mb_substr($temp, $k, 1);
}
}
echo $t;
$load_list =array(
array('user_name' => 'xiaodg'),
array('user_name' => 'x42466'),
array('user_name' => 'etea'),
array('user_name' => 'na0617'),
array('user_name' => 'kimo'),
array('user_name' => '留影'),
array('user_name' => 'vian22'),
array('user_name' => 'qingyu'),
array('user_name' => 'jiangliman'),
array('user_name' => 'xiaobu'),
array('user_name' => 'xiaobu'),
array('user_name' => 'hfa818'),
);
foreach($load_list as $k=>&$v){
$temp=$v['user_name'];
//判断是否有中文
if(preg_match('/[\x81-\xfe][\x40-\xfe]/',$temp)){
mb_internal_encoding("gbk");
}else {
mb_internal_encoding("utf-8");
}
$len = mb_strlen($temp);
$t = '';
for($k=0; $k<$len; $k++){
if($k>2) {
$t .= '*';
}else {
$t .= mb_substr($temp, $k, 1);
}
}
$v['user_name'] = $t;
}
print_r($load_list);
Array
(
[0] => Array
(
&n