Home >Backend Development >PHP Tutorial > foreach结合samrty 数据如何不显示呢

foreach结合samrty 数据如何不显示呢

WBOY
WBOYOriginal
2016-06-13 12:33:06796browse

foreach结合samrty 数据怎么不显示呢
$load_list是一个二维数组,其中的$v['user_name']有以下数据
xiaodg,
x42466,
etea,
na0617,
kimo,
留影,
vian22,
qingyu,
jiangliman,
xiaobu,
xiaobu,
hfa818,实现的结果将两个字符后面的用*代替,下面是实现*代码,
foreach($load_list as $k=>&$v){
//print_r($v);
//exit;
$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   if($k>2) {
    $t .= '*';
  }else {
   $t .= mb_substr($temp, $k, 1);
  }
}
$t=&$v['user_name'];

}

这是assign赋值:
$GLOBALS['tmpl']->assign("load_list",$load_list);

然后在页面用samrty显示:
{foreach from="$load_list" item="load"}



{$load.user_name}



但是显示的结果是xiaodg没有了,从第二个x42466开始显示
这是结果图:


foreach
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn