read and parse a single line file

  • Thread starter Rainer Weikusat
  • Start date
R

Rainer Weikusat

George Mpouras said:
the last character is missing

*YYYYMMDD* *12*

Nope. The last character in the file is a \n and that's not supposed to
be part of the $count value

------------
system('echo 20140403 100 >/tmp/x');
open($fh, '<', '/tmp/x');
$date=substr($_,0,-2-length($count=substr($_,rindex($_,' ')+1,-1)))for<$fh>;
printf("'%s', '%s'\n", $date, $count);
------------
 
G

George Mpouras

Στις 3/4/2014 22:37, ο/η Rainer Weikusat έγÏαψε:
Nope. The last character in the file is a \n and that's not supposed to
be part of the $count value

------------
system('echo 20140403 100 >/tmp/x');
open($fh, '<', '/tmp/x');
$date=substr($_,0,-2-length($count=substr($_,rindex($_,' ')+1,-1)))for<$fh>;
printf("'%s', '%s'\n", $date, $count);

my file have not final \r or \n ... so a xor maybe is necessary
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,787
Messages
2,569,627
Members
45,329
Latest member
InezZ76898

Latest Threads

Top