PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 9th, 2010, 03:51 PM
45 ACP 45 ACP is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2010
Posts: 1 45 ACP User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 11 sec
Reputation Power: 0
Reading line breaks in Filesystem

Hi,
I'm reading information from a text file which has peculiar formatting, it looks like this:
Code:
 32  29  26  49  42  61  52  43  28  48 
 46  55  60  60  109  52  6  0  3  1  1 
 1990  5  2  450000  0  2009  6  20  20 
JOE JOHNSON
 12  23  78  52

I'm trying to dump all that information into an array. So I have my script read all the information character by character: when it's an empty space, it skips. When it's a number, the number is placed in a temporary string variable and the script checks to see if the next character is another number, or else it sends the string to the array. When it's anything else, like in the case of the JOE JOHNSON line, it captures the entire line with fgets and sends that off as an array element. Simple enough.

Problem is, when my script hits a line break, it sees that it is neither a number nor an empty space, and places the line break (which comes out as nothing in HTML format) in an array element. So instead of having 35 elements in the above example, I have 39. Is there any way for me identify that the file pointer is reading a line break, so I can tell my script to skip those?

Sorry about the complication, thanks a lot!
-45

Reply With Quote
  #2  
Old February 18th, 2010, 01:47 PM
joyo joyo is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2010
Posts: 1 joyo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 50 sec
Reputation Power: 0
you can use preg_replace function to replace all the none display character to a space at first.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Reading line breaks in Filesystem


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap