请问版猪
程序员文章站
2022-06-02 08:51:10
...
$s = '我是一个人TKPC11090987是你TKPC10090987吗?TKPC10098M9Y到底是谁呢?TKMR120990U9TKMR10059E56TKMR10059E56..';
$d = array(
'TKPC' => '11069',
'TKMR' => '10999',
);
echo preg_replace_callback('/(TKPC|TKMR)(\d{5}).{3}/', function($m) use ($d) {
if($m[2] $m[0]';
return $m[0];
}, $s);
请问版猪为何你给我的这段代码放到thinkphp中却运行不出来呢
{$vo.name}:
$d = array(
'TKPC' => '11069',
'TKMR' => '10999',
);
echo preg_replace_callback('/(TKPC|TKMR)(\d{5}).{3}/', function($m) use ($d) {
if($m[2] $m[0]';
return $m[0];
}, $customer[$vo['field']]);
{$customer[$vo['field']]}
{$vo.name}:
$d = array(
'TKPC' => '11069',
'TKMR' => '10999',
);
echo preg_replace_callback('/(TKPC|TKMR)(\d{5}).{3}/', function($m) use ($d) {
if($m[2] $m[0]';
return $m[0];
}, $customer[$vo['field']]);
{$customer[$vo['field']]}
{$vo.name}:
$d = array(
'TKPC' => '11069',
'TKMR' => '10999',
);
echo preg_replace_callback('/(TKPC|TKMR)(\d{5}).{3}/', function($m) use ($d) {
if($m[2] $m[0]';
return $m[0];
}, $customer[$vo['field']]);
{$customer[$vo['field']]}
有的
有值,从数据库里面读取出来的字段
$d = array(
'TKPC' => '11069',
'TKMR' => '10999',
);
echo preg_replace_callback('/(TKPC|TKMR)(\d{5}).{3}/', function($m) use ($d) {
if($m[2] $m[0]';
return $m[0];
}, $s);
请问版猪为何你给我的这段代码放到thinkphp中却运行不出来呢
回复讨论(解决方案)
运行不起来?报错吗?
可以运行,没有报错。单独只运行这一段的话可以正常显示。但是放到thinkphp里面就显示不出红色了。
手误? 况且这跟thinphp没啥关系嘛,你放在啥地方
先试试正确关闭PHP标签
手误? 况且这跟thinphp没啥关系嘛,你放在啥地方
$d = array(
'TKPC' => '11069',
'TKMR' => '10999',
);
echo preg_replace_callback('/(TKPC|TKMR)(\d{5}).{3}/', function($m) use ($d) {
if($m[2] $m[0]';
return $m[0];
}, $customer[$vo['field']]);
{$customer[$vo['field']]}
先试试正确关闭PHP标签
$d = array(
'TKPC' => '11069',
'TKMR' => '10999',
);
echo preg_replace_callback('/(TKPC|TKMR)(\d{5}).{3}/', function($m) use ($d) {
if($m[2] $m[0]';
return $m[0];
}, $customer[$vo['field']]);
{$customer[$vo['field']]}
运行不起来?报错吗?
$d = array(
'TKPC' => '11069',
'TKMR' => '10999',
);
echo preg_replace_callback('/(TKPC|TKMR)(\d{5}).{3}/', function($m) use ($d) {
if($m[2] $m[0]';
return $m[0];
}, $customer[$vo['field']]);
{$customer[$vo['field']]}
在模板里?
$customer[$vo['field']] 有值吗?
在模板里?
$customer[$vo['field']] 有值吗?
有的
PC型号 | 固资编号 | 应用场景 |
HP3380 | TKPC10098904 | 办公机 |
LenovoM8500T | TKPC08090908 | 体验机 |
在模板里?
$customer[$vo['field']] 有值吗?
有值,从数据库里面读取出来的字段