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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:55:11+00:00 2026-06-08T22:55:11+00:00

All, Been trying to fix this issue for some time without any progress… Any

  • 0

All,

Been trying to fix this issue for some time without any progress… Any feedback is more than welcome.

We are using simple auth based on users caller id and YoB – if he has unique YoB, he can access the service, if there’s another user under that caller id with the same YoB: he gets a message that additional info is required.

The goal of a function is to return a record of a matching user – at the moment, it returns always the last record.

PHP Code:

// $response -> XML record with firstName, lastName and dob (dd/mm/yyyy) 
// $yob -> YoB user has entered for authentication  

function parseResponseYOB($response, $yob) 
{ 
    $duplicates = 0; // If there are users with same YoB, display message that additional info is required 

    if(empty($response->CallerMembers->CallerMemberDetails->dob)) 
    { 
        $iterateArr = $response->CallerMembers->CallerMemberDetails; 
    }else{ 
        $iterateArr[] = $response->CallerMembers->CallerMemberDetails; 
    } 

    foreach($iterateArr as $result) 
    { 
        $parseResult['firstName'] = $result->firstName; 
        $parseResult['lastName'] = $result->lastName; 
        $parseResult['yob'] = substr($result->dob, -4); 

        if($parseResult['yob'] == $yob) 
        { 
            $duplicates++; 
        }else{ 
            continue; 
        } 
     }
// Check for duplicate YoBs 

    if($duplicates > 1) 
    { 
        return "Multiple members with the same YOB"; 
    }elseif($duplicates < 1){ 
        return "No members with the specified YOB found"; 
    }     

    return $parseResult; // No duplicates, return the record of the matching user 
    // PROBLEM: Always the last record is returned... not the one with matching YOB? 
    } 
}  
  • 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-08T22:55:13+00:00Added an answer on June 8, 2026 at 10:55 pm

    That would be because that’s exactly what you told it to do. You’re currently writing every result into $parseResult – and overwriting the last result in the process – before you even check if it’s the right one. You’re also making the return call (as well as the checks) from within the foreach loop, which would actually terminate the loop after the first iteration. What you want is probably more like this:

    function something ($arg1, $arg2) {
    $parseResult;
    //...
    foreach ($iterateArr as $result) {
        if (substr($result->dob, -4) == $yob) {
            $parseResult['firstName'] = $result->firstName; 
            $parseResult['lastName'] = $result->lastName; 
            $parseResult['yob'] = substr($result->dob, -4); 
            $duplicates++;
        }
    }
    // Check for duplicate YoBs 
    
    if($duplicates > 1) 
    { 
        return "Multiple members with the same YOB"; 
    }elseif($duplicates < 1){ 
        return "No members with the specified YOB found"; 
    }     
    
    return $parseResult; // No duplicates, return the record of the matching user 
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, I have been trying to fix this for about two months. It all
I've been trying to fix this problem almost all day (or it feels like
I've been trying to fix this problem for a while and have exhausted all
Afternoon all, I've been slaving at this for 2 days trying to fix the
I have been trying to fix this issue for weeks but I'm at the
This issue has been driving me crazy all morning. I've been trying to get
I have been trying all day to get some data properly formatted in a
I've been trying to figure out how to do this all afternoon, but can't
I've been trying to figure this out all morning. Is there a way to
I have been trying to fix this problem for hours. My app keeps crashing

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.