php怎么去掉字符串空行

2022-01-21,

php去掉字符串空行的方法:1、创建一个PHP示例文件;2、通过“function DeleteHtml($str){...}”方法去掉html中的空行或空白即可。

本文操作环境:Windows7系统、PHP7.1版、DELL G3电脑

php怎么去掉字符串空行?

PHP去掉html中的空行、空白函数

function DeleteHtml($str){  
                    $str = trim($str);  
                    $str = ereg_replace("\t","",$str);  
                    $str = ereg_replace("\r\n","",$str);  
                    $str = ereg_replace("\r","",$str);  
                    $str = ereg_replace("\n","",$str);  
                    return trim($str);  
                }

推荐学习:《PHP视频教程》

以上就是php怎么去掉字符串空行的详细内容,更多请关注北冥有鱼其它相关文章!

本文转载自【PHP中文网】,希望能给您带来帮助,苟日新、日日新、又日新,生命不息,学习不止。

《php怎么去掉字符串空行.doc》

下载本文的Word格式文档,以方便收藏与打印。