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

  • Home
  • SEARCH
  • 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 7871725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:59:28+00:00 2026-06-03T01:59:28+00:00

Couldn’t find anything about this on the internet, or stackoverflow?!? Basic Example: A great

  • 0

Couldn’t find anything about this on the internet, or stackoverflow?!?

Basic Example:

A great example of what I want to know is, how would you create an if statement that returns true if it finds a word or phrase in a sentence.

Another Example:

Let’s say we have an IP blocklist in an external file. So I presume we’ll need to use file_get_contents somewhere in the if statement.

// IP Blocklist
118.92.00
119.92.11
125.23.10

Ok so that’s our example IP blocklist. How would you create an if statement that is able to find the middle IP (119.92.11), even though there is other content there (keeping in mind it could very well change!)?

  • 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-03T01:59:30+00:00Added an answer on June 3, 2026 at 1:59 am

    Your two examples would require two different techniques to be reliable.

    Example 1 simply requires strpos():

    if (strpos($subjectString, $searchString) !== FALSE) {
      // substring exists
    } else {
      // substring doesn't exist
    }
    

    You could use stripos() instead if you want to match in a case-insensitive manner.

    For example two it would be better to use an array. This is because the strpos() approach would match 11.22.22.11 if 11.22.22.110 was in the array – and you don’t want this.

    Instead, you would do something like this, using in_array():

    // Get a list of IPs from file and split into an array
    $ips = preg_split('/\s+/', trim(file_get_contents('list-of-ips.txt')));
    
    if (in_array($searchIP, $ips)) {
      // IP exists
    } else {
      // IP doesn't exist
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Couldn't find anything on this with a Google Search. Does anyone know how to
I couldn't find any documentation about this... I want to write to a file
Couldn't find anything about this topic. I have a Windows TCP C++ server application
Couldn't find anything really useful for my needs. So if I already know my
Couldn't find anything relevant in forums So ,Please help me with this code .I'm
Couldn't find any documentation about this: what is the order of execution of the
I couldn't find a suitable title for this. I'm going to express my query
I couldn't find a straight answer to my question and need to know it
I couldn't find anything that rejects or confirms whether SQL Server 'MONEY' data type
I couldn't find a more descriptive title, but here there is an example: import

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.