rename the file


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

File.txt

Code: ***DOCUMENT***
..DN:
Did you know?Explore Trending and Topic pages for more stories like this.
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
78 Like 48 Dislike
Previous forums Next forums
Other forums

Java API in PHP?
I have an application that we use internally here at the office.

The software company provide

Using two $_POST Function / Switch () statements, second does not work.
Hi all. I’m new to php and am having a problem getting $_POST Function / switch () to work. I

Merger of 6 sister companies under one flagship company after go live
Dear Experts,
I need one help regarding Merger of sister companies of same group. currently we

this code is strange !
Hi i got this code from the web.. It checks for live and dead socks
It is working perfectly on my

Allegro crashes when running load_bitmap. Why?
I can not get Allegro to load any BMP images. Here is a section of test code. The picture is in the

import table with dependency
Hi

What is the best way to import table back which has dependency?

SQL> cre

phpmailer class & pop.gmail.com?
Code: <?php
$mail->IsSMTP();
$mail->Host = "pop.gmail.com";

admin with my register system?
Hey i wana make it so i can make a admin level on my register system , I'm kinda new to php to im no

Strange Oracle Query problem
Ok So I have this PHP class that talks to a Javascript class that basically creates a table of infor

 formating when pulling data from a mysql database 
Ok so Im not to sure if this is the right thread to post in but here is my catch 22 issue.

I

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