PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Thu Nov 14, 2019 12:48 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Finding newline chars
PostPosted: Mon Jun 06, 2005 7:41 am 
Offline
Forum Commoner
User avatar

Joined: Sat Mar 27, 2004 10:49 pm
Posts: 38
Location: Australia
Hi,
I havn't really gotten to much into String matching and Regex but I was just wondering if there was a simple way of finding if a string has a newline character at the end of it (\n).


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 06, 2005 8:18 am 
Offline
Breakbeat Nuttzer
User avatar

Joined: Wed Mar 24, 2004 8:57 am
Posts: 13098
Location: Melbourne, Australia
Try this

Syntax: [ Download ] [ Hide ]
$string = "foo

bar

"
; //Ends on newline



if (preg_match('/\n$/', $string)) {

   //End on newline

} else {

   //End some other way

}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group