时间:2021-07-01 10:21:17 帮助过:33人阅读
1,用preg_replace替换
代码如下:
$test = " dfadad 论责民与三英的关系775fd ";
$test = preg_replace('/^( |\s)*|( |\s)*$/', '', $test);
var_dump($test);
//结果如下:
string 'dfadad 论责民与三英的关系775fd' (length=35)
2,trim方法
代码如下:
$test = " dfadad 3333adf775fd ";
$test = trim(html_entity_decode($test),chr(0xc2).chr(0xa0));
var_dump($test);
//结果如下:
string 'dfadad 3333adf775fd' (length=19)