PHP去除回车换行的三种方法


    1. <?php   
    2.  //php 不同系统的换行  
    3. //不同系统之间换行的实现是不一样的  
    4. //linux 与unix中用 /n  
    5. //MAC 用 /r  
    6. //window 为了体现与linux不同 则是 /r/n  
    7. //所以在不同平台上 实现方法就不一样  
    8. //php 有三种方法来解决  
    9.       
    10. //1、使用str_replace 来替换换行  
    11. $str = str_replace(array("/r/n""/r""/n"), ""$str);   
    12.       
    13. //2、使用正则替换  
    14. $str = preg_replace('//s*/', '', $str);  
    15.       
    16. //3、使用php定义好的变量 (建议使用)  
    17. $str = str_replace(PHP_EOL, ''$str);   
    18. ?> 

原文地址:http://blog.micxp.com/index.php/archives/51/


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM