NYCPHP Meetup

NYPHP.org

[nycphp-talk] What does this code do?

Michael Hernandez sequethin at gmail.com
Mon Mar 3 13:18:25 EST 2008


on windows a new line is really 2 characters, carriage return and line  
feed. In unix it's 2-in-1. The idea is to convert them you need to  
replace the carriage return and line feed with a newline character.

if you don't know what \r or \n are you should most definitely do some  
rtfmming :)

Good luck :)

--Mike H


On Mar 3, 2008, at 1:12 PM, -- rada -- wrote:

> Hi all,
>
> I am trying to implement a user-input scrubbing function, more  
> specifically, normalize linebreaks from windows/mac to unix. I can  
> just do preg_replace but I saw this piece of code somewhere and  
> don't understand it enough to even know what to google.
>
> supposedly converts Windows CRLF  to Unix LF:
> $str =~ s/\r\n/\n/g;
>
> What does =~ do? I can RTFM if you point me to it :)
>
>
> Never miss a thing. Make Yahoo your homepage.  
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20080303/9a1e1656/attachment.html>


More information about the talk mailing list