帝国cms PHP怎么截取两个中文字中间的字符串?

www.96kaifa.com | 2021-11-20 |

php写法:

<?php

header('Content-Type:text/html;charset=utf-8');

$str="神叨侠第10期:里约奥运会有啥好看的?";

$t1 = mb_strpos($str,'第');

$t2 = mb_strpos($str,':');

echo $s = mb_substr($str,$t1,$t2-$t1);

?>

在帝国cms里的运用很简单,直接把$str="神叨侠第10期:里约奥运会有啥好看的?";中文部分换成帝国cms的变量就行了,如下:

<?php

header('Content-Type:text/html;charset=utf-8');

$str=$navinfor['title'];

$t1 = mb_strpos($str,'第');

$t2 = mb_strpos($str,':');

echo $s = mb_substr($str,$t1,$t2-$t1);

?>