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 7690417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:23:29+00:00 2026-05-31T20:23:29+00:00

I think i was doing halfway good to get this to halfway work. Anyways

  • 0

I think i was doing halfway good to get this to halfway work. Anyways the following code works to find it on the first line, but i have a script that creates each on an individual line.
Please revise or create a completely new version of the following to make it to search for the form data on every line.

$search = $_POST['search'];
$file = file("SLIST.txt");
foreach($file as $line) 
{
    $line = trim($line);
    if($line == $search) 
    {
        echo $search . " WAS found in the database";
    }
    else 
    {
        echo $search . " was NOT found in the database";
    }
}

by form i mean there is a search form on the previous page. This page is the page where it tells you whether the text put into the search form matches a line in the file (ex: Line 1: BOOT Line 2: Tree Search entry: Tree Echo msg: Tree WAS found in the database.)

It is currently not working like i intended.

  • 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-05-31T20:23:31+00:00Added an answer on May 31, 2026 at 8:23 pm

    If you only want to know if the search string was in the file, and don’t care on which line, then strpos() (doc) with file_get_contents() might be for you like this:

    $file = file_get_contents('SLIST.txt');
    $search = $_POST['search'];
    
    if (strpos($file,$search)){
        echo $search . " WAS found in the database";
    }
    else 
    {
        echo $search . " was NOT found in the database";
    }
    

    If you want to know the line, your solutions should work as well if you change the if($line == $search) with my strpos().

    If the line has to be exactly the search query you are looking for, then your solution should work just fine

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First off, I know I can copy "this" on instantiation, but that doesn't work
OK... This is confusing me...I have a way I can think of doing this...but
Think about doing this: import matplotlib.pyplot as plt plt.plot(x_A,y_A,'g--') plt.plot(x_B,y_B,'r-o') plt.show() How would you
I'd like to save my screen in bmp; but a think I'm doing it
I've been doing some research and I think I know the answer already, but
Ok, I think whatever I'm doing wrong, it's probably blindingly obvious, but I can't
I was doing this: (String[]) myTreeSet.toArray(); but that gives me a ClassCastException at runtime.
Specifically this: p:first-child:first-letter {font-size:48px;} Works in all browsers (even IE8 for crying out loud)
hello ive been trying to get the current environment in rails but i think
This isn't a complicated problem, but I can't for whatever reason think of a

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.