Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8544423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:33:15+00:00 2026-06-11T12:33:15+00:00

What Im Trying to do here is set up some sort of filter. I

  • 0

What Im Trying to do here is set up some sort of filter.

I have no source code at the moment, but I can type it up quick after i find out how to do this.

So Say I have

$Variable1 = "The Brown Fox Jumps";

I want a If statement where

IF $Variable1 contains a word from a .txt file (filter.txt) Then $Variable1 = "Filtered"

so if the text file contained

Hey
Hi
Jump
Brown

It would change the whole thing to filtered. I Dont know how I would write that, so a little help typing it would be nice 🙂

Thanks Guys

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T12:33:16+00:00Added an answer on June 11, 2026 at 12:33 pm

    If you file is delimeted by newlines:

    $file = file_get_contents('filter.txt');
    $bad_words = explode(PHP_EOL, $file); // If PHP_EOL doesn't work there are other EOL characters you can try.
    $variable1 = "This is some string."
    $compare = explode(' ', $variable1);
    if(count(array_intersect($bad_words, $compare)) > 0){
      $variable1 = 'Filtered';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hopefully someone here can help me! I'm trying to set up fancybox so when
Well I am trying to sort some data in PHP. Here is an example
I'm trying to create small application on Yii framework but can't understand one moment.
Trying to rephrase/clean up question here: I'm trying to do some sort of conditional
Here's my problem: I'm trying to set up a simple mobile contact form with
I'm trying to set up the SC html 5 api located here: http://w.soundcloud.com/player/api.js However
I'm trying to set my entirely table row as an anchor. I've read here
New to Pyramid here, and trying to set up pyramid_mailer to send an email
Beginner here trying to get a pipeline working in bash. If somebody can see
I know of the ||= operator, but don't think it'll help me here...trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.