在php中去掉字符串中空格的方法
1.使用trim函数去除字符串首尾两端的空格
$str = ' Hello world! ';
echo trim($str);
输出结果为:
Hello world!
2.使用ltrim函数去除字符串首部的空格
$str = ' Hello world! ';
echo ltrim($str);
输出结果为:
Hello world!
3.使用rtrim函数去除字符串尾部的空格
$str = ' Hello world! ';
echo rtrim($str);
输出结果为:
Hello world!
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:vb怎么去掉字符串中的空格