rename the file


Posted on 16th Feb 2014 07:03 pm by admin

File.txt

Code: ***DOCUMENT***
..DN:
000044255
..CB:
..SN:
..PY:
2009
..ED:
LA
..ED:
Home
..ID:
***DOCUMENT***
..DN:
000044254
..CB:
..SN:
..PY:
2009
..ED:
LA
..ED:
Edition
..PT:
ID:

Code: <?php
$file = fopen($argv[1], "r") or exit("Unable to open file!");
$i=1000;
while(!feof($file)){
while(!feof($file))
{
$line=fgets($file);
if(strstr($line,"***DOCUMENT")){

$file1 = fopen($argv[1].$i.".txt",'w') or exit("Unable to open file!");
}
fwrite($file1,$line);
if(strstr($line,'..ID:')){
fclose($file1);
break;
}
}
$i++;
}
fclose($file);
?>


Hi,

This is the above file. I have splitted this file naming starting with 1000.txt.....
How to name taking the value of ED.
I have to name it as 1000.Home.txt
1001.Edition.txt

No comments posted yet

Your Answer:

Login to answer
307 Like 31 Dislike
Previous forums Next forums
Other forums

PHP If Else statement for breadcrumb
Hi

I am trying to use a PHP if else statement to display a breadcrumb link on wordpress

phpMailer will not connect using SMTP
I am trying to use phpMailer with smtp:

Code: [Select]$mailer = new PHPMailer();
$mailer-&

compile php5 with DOM
Hi,

I can't manage to compile php 5.3.0 from source on Windows to include DOM,
in spite of

MII Trends - add data onto chart object
Hello,

Can anyone please provide some thoughts on my current requirement:
its pretty

Inter Company -- Resources Related Billing (Services Industry)
Hello,

My company has a scenario where:
Company A bills Company C for INTER (cross

ALV grid with 2 headers
Hi Gurus,

I need to display ALV GRID as below.

Header1

serializing objects - loses methods - the point being?
Hi

I know that serializing an object will lose the methods. But whats the point in that? What

Email "$"
Hello!!

Any PHP guy with a bit of a knowledge in Flash ?

When I send a JPEG from flash

MySql timezone
Code: $sql = "SELECT *, date_format(date, '%m/%d/%Y at %I:%i %p' )as date FROM comments WHERE t

Thought I has this figured out especially after all the help i received?
Cags, Salathe, Daniel helped me with this yesterday, but not sure i took it all in.
I am attempti

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash