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

Displaying a clickable playername
I am going wrong somewhere with the mysql_query, can someone please put me straight?

$playern

Getting Resource id #11 while trying to connect..
So i tried using "DEFINE" for the first time and im using the variables i defined to conne

why does my session end?
my connect.php starts the session just so you know
i can navigate arround my site fine except whe

Change snippet to use CURDATE
I am using time() in the snippet below, I would like to use CURDATE() and have the database setup fo

Creating a custom API
I'm creating a site, and I need to create a basic API. Unfortunately I have no idea where to start.

insert PHP code into function
Hi,
I'm having problems when trying following:

I have:
Code: [Select]createBar("Do

Why does my crawler script suddenly end with no error?
Hi.

I have written a web crawler script. It will visit a large number of URL's with cURL.

Unidentified index error in a simple form
I have been trying to make an HTML form that is handled by a PHP script. So far my attempts to get i

IF STATEMENT HELP
Hi
i have created a calendar from a table:

Code: Calendar: October 2009
<table w

Code working in IE but not FireFox
I created a dynamic navigation list for my website based off of a table in my database. The code is

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