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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:34:47+00:00 2026-06-10T00:34:47+00:00

I have data here: First, the result of my first function named getsiteaccounts() Array

  • 0

I have data here: First, the result of my first function named getsiteaccounts()

Array
(
[0] => Array
    (
        [SiteID] => 2
        [AID] => 5
    )

[1] => Array
    (
        [SiteID] => 2
        [AID] => 3
    )
[2] => Array
    (
        [SiteID] => 6
        [AID] => 4
    )

And the result of my second function named bindGHComponentsToSites()

   Array
  ( 
  [2] => Array
    (
        [SiteID] => 2
        [Balance] => 19000.00
        [MinBalance] => 100000.00
        [MaxBalance] => 1000000.00
        [OwnerAID] => 5
        [GroupID] => 1
        [Deposit] => 1500
        [Reload] => 1000
        [Redemption] => 1000
    )

)

Then, add the key of [CorpAID] pointing to the list of OwnerAID. BY the way, OwnerAID and AID are the same. As you can see SiteID => 2 owned by two OwnerAID => 5 and 3. Here’s should be the result:

   Array([0])=> Array (
        [SiteID] => 2
        [Balance] => 19000.00
        [MinBalance] => 100000.00
        [MaxBalance] => 1000000.00
        [OwnerAID] => 5
        [GroupID] => 1
        [Deposit] => 1500
        [Reload] => 1000
        [Redemption] => 1000
        [CorpAID] => Array(
                   [0] => 5
                   [1] => 3
        )
      )
  )

The SiteID => 6 should not be print since it only owned by one AID. Is it possible to make it? Please guide me in proper way. Thank you in advance.

  • 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-10T00:34:48+00:00Added an answer on June 10, 2026 at 12:34 am

    You can use a couple of foreach loops to do what you need:

    <?php
    
    $siteAccounts = array(
      array('SiteID'=>2, 'AID'=>5),
      array('SiteID' => 2, 'AID' => 3),
      array('SiteID' => 6, 'AID' => 4)
    );
    
    $componentsToSites = array(array(
      'SiteID' => 2,
      'Balance' => 19000.00,
      'MinBalance' => 100000.00,
      'MaxBalance' => 1000000.00,
      'OwnerAID' => 5,
      'GroupID' => 1,
      'Deposit' => 1500,
      'Reload' => 1000,
      'Redemption' => 1000
    ));
    
    foreach ($componentsToSites as &$site) {
      $aids = array();
      foreach ($siteAccounts as $acct) {
          if ($acct['SiteID'] === $site['SiteID'])
            $aids[] = $acct['AID'];
      }
      $site['CorpAID'] = $aids;
    }
    
    print_r($componentsToSites);
    

    Edit:

    My original answer used array_walk rather than foreach, but due to compatibility issues I switched it. Here is the original code snippet for using array_walk:

    array_walk($componentsToSites, function (&$site) use ($siteAccounts) {
      $aids = array();
      array_walk($siteAccounts, function ($acct) use ($site, &$aids) {
          if ($acct['SiteID'] === $site['SiteID'])
            $aids[] = $acct['AID'];
      });
      $site['CorpAID'] = $aids;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a outsource data from : http://example.com/data/news.json Here is the example result after
I have hourly weather data. I've seen the function examples from here: http://casoilresource.lawr.ucdavis.edu/drupal/node/991 I'm
I have two functions named ChangeText() & ChangeColor(), the first function called ChangeText who
I'm trying to pass an array to jquery's .ajax() function's data parameter. The first
So here's the problem. I have data in a MySQL DB as text. The
Here's the problem: I have a data-bound list of items, basically a way for
Here's the issue: I have 2 data contexts that I would like to do
I'm learning assembly and I have a very basic loop here segment .data msg:
I have used the method described here to localize my data annotation messages and
I have been running around here and there on NoSQL big data storage technologies.

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.