/    Sign up×
Community /Pin to ProfileBookmark

Creating snippet

I would like to include a portion of the text from the content area of one page (A) as a “snippet” on my websites home page (?. The text in the content area on page (A) comes from a text file via php [I]include[/I]. I know I can use ‘[I]substr[/I]‘ to display the number of characters I want on page (? as the snippet but I can’t seem to figure out how to retrieve to text from the text file. I can’t seem to use [I]include[/I] and [I]substr[/I] for the snippet text, I’m assuming because of the way it’s executed.

I do not currently have a database is the reason for the include file.

The text file is updated by users and I would like for the ‘snippet’ to reflect what the current discussion is whenever the home page is loaded.

I am new to php and would appreciate any help or guidance you can give.

Thanks

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@keno2113authorMar 21.2006 — Never mind. I knew If I just researched it a little longer I would find the solution, and I did.

For any other newbies out there, like myself, if your interested here it is:

[code=php]
$myfile = substr(file_get_contents('file.txt'),0,105);
echo $myfile;
[/code]
×

Success!

Help @keno2113 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...