/    Sign up×
Community /Pin to ProfileBookmark

show TXT into php

hey.

i have a program that updates a .txt file with loginformation. i wonder if i somehow can make a .php file include the contents of a .txt into the php file when the page is loaded so it’s displayed.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@CharlesMay 16.2007 — [code=php]<?php include 'some-filename.txt' ?>[/code]
Copy linkTweet thisAlerts:
@izlikauthorMay 16.2007 — ow it works with include? i tryed it but i most have done someting wrong ? thanks, goan try again.
Copy linkTweet thisAlerts:
@hastxMay 16.2007 — The easiest way is probably file_get_contents()

[code=php]
$text = file_get_contents('filename.txt');
echo "$text";
[/code]


or you could put the lines of the file into an array to expand your ability to work with the data

[code=php]
$lines = file('filename.txt');
foreach ($lines as $line){
echo "<p>$line</p>";
}
[/code]
×

Success!

Help @izlik 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.18,
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,
)...