/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] writing to a file

I was wonding what the code line would be to see if something is in a file?(would appriciate if you would include comments as i like to know what the code does so i can learn)

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@bathurst_guyApr 02.2006 — Have you searched first???

Try reading through some of [url=http://www.webdeveloper.com/forum/search.php?searchid=1072959]these posts[/url], I'm sure you will find your answer.
Copy linkTweet thisAlerts:
@balloonbuffoonApr 02.2006 — [code=php]
//get the entire contents of a file
$contents = file_get_contents($filename);

//determine whether the string ($find) is anywhere in the file
//strpos() finds the position of a string ($find) inside of another string ($contents)
//if it is not found, it will return false
if (strpos($contents, $find)===false) {
//do something if string isn't in file
} else {
//do something if string *is* in file
}
[/code]


--Steve
Copy linkTweet thisAlerts:
@balloonbuffoonApr 02.2006 — And if you need case-insensitive searching, replace strpos() with stripos().

--Steve
Copy linkTweet thisAlerts:
@Heavy_MetalauthorApr 02.2006 — And once again you all come through for me. You guys rule.?
Copy linkTweet thisAlerts:
@Heavy_MetalauthorApr 02.2006 — how do you run a function when a form submits?
Copy linkTweet thisAlerts:
@Heavy_MetalauthorApr 02.2006 — no answers?
Copy linkTweet thisAlerts:
@NogDogApr 02.2006 — no answers?[/QUOTE]
Dude, it's Saturday night, Final 4 on TV, and you want a response after only 20 minutes - on a thread that's marked as resolved?

How about starting a new thread since it's a new question (and this one is resolved). I'll lock this thread so potential responses don't get spread between threads.
×

Success!

Help @Heavy_Metal 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.19,
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,
)...