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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:49:43+00:00 2026-06-01T16:49:43+00:00

THE PROCESS: User checks checkboxes to share files with customer accounts Checkbox values are

  • 0

THE PROCESS:

  1. User checks checkboxes to share files with customer accounts
  2. Checkbox values are compared against an array stored in a txt file from the customers folder
  3. The arrays are compared by being merged into one array using array_merge()
  4. The duplicates are eliminated using array_unique()
  5. New array written to txt file

THE PROBLEM:

If my text file already contains the following data: (numbers representing text file lines)

  1. M HTH A277 Frame Off STD Specs 02-01-12.pdf
  2. M HTH A277 Frame On STD Specs 02-01-12.pdf
  3. M HTH Option Can Price List 02-02-2012.xls

I then try to share more files including those that are already shared. My new text file looks like this: (numbers representing text file lines)

  1. M HTH A277 Frame Off STD Specs 02-01-12.pdf
  2. (blank)
  3. M HTH A277 Frame On STD Specs 02-01-12.pdf
  4. (blank)
  5. M HTH Option Can Price List 02-02-2012.xls
  6. (blank)
  7. (blank)
  8. M HTH A277 Frame Off STD Specs 02-01-12.pdf
  9. M HTH A277 Frame On STD Specs 02-01-12.pdf
  10. M HTH Option Can Price List 02-02-2012.xls
  11. Valley Creek Estates – 2010.pdf

The values above are the exact values I’m dealing with. I’ve tried to be as thorough as possible with this explanation which could make things confusing. If anyone can provide me with any suggestions they would be greatly appreciated. Thanks in advance. This is what I’ve got for code so far:

THE CODE:

$arr = $_POST['checked'];
$cust = $_POST['custname'];

    if ($cust != ""){

        $myFile = "CONTA.txt";

        //If file exists get previous array from file
        if (file_exists("customer/" . $cust . "/" . $myFile)) {         

            $fh = fopen("customer/" . $cust . "/" . $myFile, 'r') or die("");

                while (!feof($fh) ) {
                        $compare[] = fgets($fh);
                }

            fclose($fh);

            //Combine checkbox array with previous array & eliminate duplicates

            $combined = array_unique(array_merge($compare,$arr));

        }
        else
        {

            //Since no previous file or array existed. Just use current checkbox array.     
            $combined = $arr;


        }

        //Input array into file
        $fh = fopen("customer/" . $cust . "/" . $myFile, 'w') or die("can't open file");

            foreach ($combined as $value) {

                    fwrite($fh, $value . "\n");

            }
        echo "<span class='message'>Items shared successfully!</span>";
        fclose($fh);
    }

}
  • 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-01T16:49:44+00:00Added an answer on June 1, 2026 at 4:49 pm

    To me it looks like the problem is “\n” character. Each line has a new line on the end and when you compare one line that has the newline character and the same line that doesn’t they aren’t the same. I would confirm this by echoing each line from the fgets. If they are line broken, then you know you are getting the new line character.

    EDIT:
    I would try putting
    trim(fgets($fh))
    by default it should strip the newline character
    trim specs

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

Sidebar

Related Questions

I have a checkBox in my Windows application called Continuous. When user checks this
I am working on a script that will process user uploads to the server,
I have two processes - a user process and a root-level LaunchDaemon. I'd like
In C# the StartTime function shows only the user process run time. Are there
I have a process where a user puts in a comma delimited list that
Is there a way to create a user-mode process from kernel-mode on Windows NT
I need to reboot a Linux box from a user space process. I want
I have a service that spawns a WPF application process when a user logs
I'm trying to implement a function to backtrace a crashed user space process in
I have to use the EXEC family to find the process owned (the user)

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.