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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:00:16+00:00 2026-05-11T22:00:16+00:00

I have an array of arrays, each array containing details of a scan by

  • 0

I have an array of arrays, each array containing details of a scan by a medical device. I’m getting this data from text logs that are dumped nightly. The format of which is this:

$this->scans = array(
  array(  
    'patientid' => (int),
    'patientname' => 'John Skeet',
    'reviewed' => 0 or 1
     //plus more irrelevant
  ),
  array(
    //same as above
  ), //etc
)

The important array key here is reviewed, as each scan may be reviewed if it is of high enough quality. However, the text logs dump out EVERY scan that is acquired, then goes back through and re-lists the ones that are reviewed.

Now in order to prevent duplicates , I figured I could just use an array_filter to filter out scans that have been both acquired and reviewed (keeping the reviewed version). However, the filter function is filtering out the entire array (except in some rare cases). If someone could take a look and let me know why they think it’s happening that would be much appreciated.

$this->scans = array_filter($this->scans, array($this, "scan_cleanup"));

.

private function scan_cleanup($scan) {
        //only if the scan was not reviewed
    if ($scan['reviewed'] == 0) {
                //change reviewed status to see if there is a duplicate
        $scan['reviewed'] == 1;
                //return false to remove this copy (and keep reviewed)
        if (in_array($scan, $this->scans)) {
            return false;
        }
    }
    return true;

}
  • 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-11T22:00:16+00:00Added an answer on May 11, 2026 at 10:00 pm
    $scan['reviewed'] == 1;
    

    vs

    $scan['reviewed'] = 1;
    

    One is a conditional, that does nothing in this context, the other is not there.

    You are also not running the return false very often. I’d change the logic a little to make it a little clearer, and simpler by a little refactoring (pulling out a condition-check).

    if ($scan['reviewed'] and hasDupe($scan)) {
       return false;  // filter out
    }
    return true; // it is passed back, and is output
    

    hasDupe() does the best checks you know for a duplicate record and returns true/false.

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

Sidebar

Related Questions

I have two arrays, each containing strings. The first array is a list of
This is an additional question from this . I have this array containing multiple
I have an array of Objects, each containing a Location and a Links array
Hey I have an array where each element is a hash containing a few
I have both matrices containing only ones and each array has 500 rows and
I have 4 string arrays,each of these array's length is 4. I also have
I have an array ($configOptions) which contains some arrays. Each array ($option) in that
Assume that we have multiple arrays of integers. You can consider each array as
My problem: I have an JSON Array containing arrays, which i render into the
I have several string each containing a JSON representation of an array of objects.

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.