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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:53:13+00:00 2026-06-07T00:53:13+00:00

I am having one hell of a time coming up with a decent way

  • 0

I am having one hell of a time coming up with a decent way make this if statement search a file for these codes. I set up the text file to read from as such:

myfile.txt

r)
0Y7
1a6
q.
@g
@(
#a
!P
T[
V}
0,

Here is a brief of what I got going.

$subject = file_get_contents(fvManager_Path . 'myfile.txt');
if ( preg_match('/^[a-zA-Z0-9,]+$/',$result['fmbushels_itemCode'], $subject) ) { 

Basically I am trying to search the text file line by line to see if the whole string exists. They are case sensitive as well.

$result[‘fmbushels_itemCode’] is from a sql query and always returns a code like the above in the text.

I’d appreciate any help on this. If someone knows a better way of doing this or a different command, I’d be willing to give that a shot as well 🙂

edit:

private function _fvShareBushels() {
$subject = file_get_contents(fvManager_Path . 'myfile.txt');

if (count($vShareArray) > 0) {
$vCntMoves = count($vShareArray);

for ($vI = 0;$vI < $vRunMainLoop;$vI++) {
sell $result['fmbushels_itemCode']);    
}
}
}

This is a snippet of a big code. I had to rip most out because of post limitation. The area I could be working with is:

if (count($vShareArray) > 0) {

If I could make this something like:

if (count($vShareArray) > 0 && $result['fmbushels_itemCode'] **is not in** $subject) {
  • 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-07T00:53:15+00:00Added an answer on June 7, 2026 at 12:53 am

    If you want to do line by line, use the file() function.

    $f = file(fvManager_Path . 'myfile.txt');
    foreach($f AS $line){
        // $line is current line at file
    }
    

    I’m not to sure if you understand completely how preg_match works. The first parameter is the regular expression pattern, the second is what you want to match the pattern to, and the third is an array of matches. So for every valid pattern matched in the second parameter a new index on the array is created.

    I’m not 100% on what you’re trying to accomplish. Are you trying to see if the $result['fmbushels_itemCode'] exists in the file?

    If the above is the correct case you simply just need to do something like:

    $f = file('myfile.txt');
    array_map('trim', $f);
    if(in_array($result['fmbushels_itemCode'], $f)){
        // success
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having one hell of a time trying to get this to work,
I'm having one hell of a time trying to get my databinding to work
I am having one heck of a hard time trying to figure this out.
Hello guys i'm having one hell of a time trying to parse an xml
I am having a hell of a time with this problem: Using MPI, I
I'm having a hell of time grasping the best way to package my Android
I'm having one hell of a headache trying to figure this out for myself,
I am having one Gtk+ and C application in which i want to set
After switching to AS3, I've been having a hell of a time figuring out
Well I'm having a hell of a time trying to get my CPU down

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.