Minichan

Topic: PHP question

Anonymous A started this discussion 15 years ago #7,979

Say I was processing a form, and I was handling very large pieces of text. If I wanted to check whether the text entered contained a particular word or character so I could tell it to die, how would I do that?
I'm new to PHP, and the only way I can think of is using an if statement. I could check whether $_POST["something"] was the word very easily - but I want to check if it just contains that word and then tell it to die (or echo something back to the user).

Halp.

protip !!pMmAiEwOm joined in and replied with this 15 years ago, 3 minutes later[^] [v] #138,617

if ( preg_match ( "/word/i", $_POST['var'] ) > 0 ) ) { die ( 'found it!' ); }

(Edited 1 minute later.)

Anonymous A (OP) replied with this 15 years ago, 6 hours later, 6 hours after the original post[^] [v] #139,163

@previous (protip !!pMmAiEwOm)
Thanks! Now, say I wanted to to do this:

nvm, worked it out

(Edited 9 minutes later.)

Anonymous C joined in and replied with this 15 years ago, 17 minutes later, 6 hours after the original post[^] [v] #139,184

Image went missing

protip !!pMmAiEwOm replied with this 15 years ago, 2 minutes later, 6 hours after the original post[^] [v] #139,189

@previous (C)
Yell at Facebook to release their interpreter ;-)
:

Please familiarise yourself with the rules and markup syntax before posting.