By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,027 Members | 1,111 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,027 IT Pros & Developers. It's quick & easy.

include part of a text file

P: n/a
hello all.

I have a text document that stores text for use in a flash movie. I'm
also using PHP to displace the same text on another page. However the
text document includes 2 tags for use by the flash movie... title= and
&content= ... see text file at end of post ....

when i use the php command <?php include ("info.txt"); ?> it also
displays those tags. Is there any way to use php to just display what
apprars after the &content= in my text file.

I can't remove the tag begause it is required for the flash file
elsewhere on the site.

"
title=CDN HOME &content=The COMPUTER DONATION NETWORK is a resource of
new, used and refurbished computer equipment, software, networking gear
and lab furnishings for "

grassy ass,
(Thank You)

Mar 10 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Assuming "&content=" isnt anywhere else in the txt file, you could use
PHPs explode function like so...

<?php
$textfile= "/usr/local/something.txt";
$handle = fopen($textfile, "r");
$contents = fread($handle, filesize($textfile));
fclose($handle);

$content = explode("&content=", $contents);
print($content[1]);
?>

fopen function..
http://www.php.net/manual/en/function.fopen.php

fread function...
http://www.php.net/manual/en/function.fread.php

explode function...
http://www.php.net/manual/en/function.explode.php

-Nathan

Mar 10 '06 #2

P: n/a
NC
br*********@i-rent.us wrote:

when i use the php command <?php include ("info.txt"); ?>
There's no need to use include() for anything other than PHP files. If
you just want to output the contents of the file, use readfile()
instead.
Is there any way to use php to just display what
apprars after the &content= in my text file. .... "
title=CDN HOME &content=The COMPUTER DONATION NETWORK
is a resource of new, used and refurbished computer equipment, software,
networking gear and lab furnishings for "


Yes:

list(, $content) = explode('&content=', file_get_contents('info.txt'));

echo $content;

Cheers,
NC

Mar 10 '06 #3

P: n/a
Thank you so much. This worked like a charm

Mar 10 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.