[PHP] search a text file

2001-03-12 Thread Peter Benoit

I've got a bit of a task where I need to poll a text file for several lines
of text which is buried deep within the file.  These lines change each day,
but the text surrounding them do not.

Is it possible to extract these lines of information based on the text
surrounding them?


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] search a text file

2001-03-12 Thread Peter Benoit

OK, I'm a little new to this, else I would have known that.  Any examples
out there I could use/modify?  

thanks,
pete

-Original Message-
From: CC Zona [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 12, 2001 2:16 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] search a text file


In article 
<[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Peter Benoit) wrote:

> I've got a bit of a task where I need to poll a text file for several
lines
> of text which is buried deep within the file.  These lines change each
day,
> but the text surrounding them do not.
> 
> Is it possible to extract these lines of information based on the text
> surrounding them?

Sure.  preg_match() would be one way.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] In my attempt to read from a text file...

2001-03-12 Thread Peter Benoit

I'm trying preg_match with no success.

I'd like to search inside the text file for my name, then pull all the info
from that point till the next name which is Fred.

The text file would be called names.txt


So I'm trying to 

preg_match("Peter",names.txt,$myname)

then do the same for Fred, and grab all the stuff in between.

Is this the right way to do this?  Or is there something easier?

How can I search names.txt?  Can I load it into a variable somehow?

Please help


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] search a text file

2001-03-12 Thread Peter Benoit

Very good info, but this text is located in a text file.  How can I
reference it this way?

-Original Message-
From: CC Zona [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 12, 2001 3:36 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] search a text file


[quotes returned to bottom-posting, for clarity]

In article 
<[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Peter Benoit) wrote:

> In article 
> <[EMAIL PROTECTED]>,
>  [EMAIL PROTECTED] (Peter Benoit) wrote:
> 
> > I've got a bit of a task where I need to poll a text file for several
> lines
> > of text which is buried deep within the file.  These lines change each
> day,
> > but the text surrounding them do not.
> > 
> > Is it possible to extract these lines of information based on the text
> > surrounding them?
> 
> Sure.  preg_match() would be one way.

> OK, I'm a little new to this, else I would have known that.  Any examples
> out there I could use/modify?  

Probably.  You could check the manual's page on preg_match (the user 
annotations often have very useful code examples), phpbuilder.com, 
hotscripts.com, etc.  A quick, oversimplified example:

Let's say your complete text was (no laughing now ) "Mary had a little 
lamb, its fleece was white as snow." where "Mary had a " and "fleece was 
white as snow." are always consistent but whatever's happens to be the 
portion of the text between them is what you want to extract.  You could do 
something like--

$search_string="Mary had a little lamb, its fleece was white as snow.";
$status=preg_match("/^Mary had a(.*)(?=fleece was white as 
snow.)$/i",$search_string,$match_text);

In which case, $status would evaluate to true if a (case-insensitive) match 
was found, and $match_text[1] would contain " little lamb, its ".

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Need to download files in IE

2001-03-12 Thread Peter Benoit

Yes, zip the pdf.  Search the MSKB for more info.

-Original Message-
From: James R. Edgar [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 12, 2001 3:50 PM
To: 'Pierre-Yves Lemaire'
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP] Need to download files in IE


Hello,

This is the URL of the link that I use.
http://www.sitename.com/pizzeria.php3?pizzeria=aldentes

Here is the code from the script.
$file_path = "menus";
$file = $pizzeria . ".pdf";
$full_file = $file_path."/".$file;
$filesize=filesize($full_file);

header("Content-disposition: attachment; filename=\"$file\"");
header("Content-type: application-download");
header("Pragma: no-cache");
header("Expires: 0");
$fn=fopen($full_file,"r");
fpassthru($fn);
fclose($fn);
exit;

I tried it and it did not work. When I click on the link it shows
"pizzeria.htm"
in the File Name field. Any other suggestions.

Regards,
Edgar

-Original Message-
From: Pierre-Yves Lemaire [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 12, 2001 10:41 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Need to download files in IE


Hello,

I do that with this piece of code. ( This will close the window, so open a
new one and put this code inside)

header("Content-disposition: attachment; filename=\"$fileName\"");
header("Content-type: application-download");
header("Pragma: no-cache");
header("Expires: 0");
$fn=fopen($FileName,"r");
fpassthru($fn);
fclose($fn);
exit;

py

- Original Message -
From: James R. Edgar <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, March 12, 2001 7:57 PM
Subject: [PHP] Need to download files in IE


> I am trying to set my script up so that when a person clicks on the link,
that
> the page will prompt for a download w/ the filename in the File Name field
in
> the Save As prompt.
> I can get this to work in Netscapse but when I try to do it with Internet
> Explorer I encounter problems. It either says there is no application to
read
> the file (I have acrobat reader on the computer.) or it displays the
prompt with
> either [variable's name passed to script].htm or download.php. And the
file I am
> trying to download is a PDF file. If anyone can help me with this I would
> greatly appreciate this, and thanks in advance.
>
> Regards,
> Edgar
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]