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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:34:03+00:00 2026-06-07T03:34:03+00:00

Ok I posted before a question that was not so clear, so let me

  • 0

Ok I posted before a question that was not so clear, so let me try again.
I am trying to organize my websites into batches of 5 sites per batch that all have different ip addresses.

To do so I must, get IP on-the-fly for each url and then organize them, the sites, into batches of 5 sites per batch, that each have there own unique IP address.

If I have multiple IP address they must be shown on the next batch.

Can anyone help my out with this issue ?

I have the an array with sites and there IP.

Here is my code :

if(isset($Organize_List)){
 $List =   explode("\n", $Organize_List);
$IP_Array = array();
      foreach($List as $SIte){
    $Ip = gethostbyname(trim($SIte));
      if(preg_match('/^\d+$/', $Ip[1])){
         $IP_Array[$Ip][] = $SIte.'<br />';
                }
 }

Now here is where it get’s tricky.

My problem is how to organize them into batches of 5 sites per batch, that each have there own unique IP address.

  • 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-07T03:34:05+00:00Added an answer on June 7, 2026 at 3:34 am
    /* your base data */
    $domains = array(/* your data */);
    
    /* a list of domains per ip number, like $domain_by_ip['64.34.119.12'] = 'stackoverflow.com' */
    $domain_by_ip = array();
    
    /* a list counting number of domains by ip number */
    $ip_count = array();
    
    /* a list of domains we faild to fetch ip number for */
    $failed = array();
    
    /* loop through all doains */
    foreach($domains as $current_domain)
    {
       /* fetch the A record for all domains */
       $current_dns_record = dns_get_record($current_domain, DNS_A);
    
       /* if there is a dns record */
       if($current_dns_record)
       {
          /* fetch ip from result */
          $current_ip = $current_dns_record[0]['ip'];
    
          /* thos row is not needed, but php may triggering a warning oterhwise */
          if(!isset($domain_by_ip[$current_ip])) $domain_by_ip[$current_ip] = array();
          if(!isset$ip_count[$current_ip])) $ip_count[$current_ip] = array();
    
          /* add domain to the list by ip */
          $domain_by_ip[$current_ip][] = $current_dns_record;
    
          /* count up the count of domains on this ip */
          $ip_count[$current_ip]++;
       }
       else
       {
          /* if there was no dns record, put this domain on the fail list */
          $failed[] = $current_domain;
       }
    }
    
    /* create a list for storing batches */
    $batches = array();
    
    /* as long as we have ip-numbers left to use */
    while($ip_count)
    {
       /* create a list for storing current batch */
       $current_batch = array();
    
       /* sort ip-numbers so we take the ip-numbers whit most domains first */
       arsort($ip_count);
    
       /* take the top 5 ip-numbers from the list */
       $current_batch_ip_list = array_slice(array_keys($ip_count), 0, 5);
    
       /* foreach of thous 5 ip-numbers .. */
       foreach($current_batch_ip_list as $current_ip)
       {
          /* move one domain from the domain by ip list to the current batch */
          $current_batch[] = array_pop($domain_by_ip[$current_ip]);
    
          /* count down the numbers of domains left for that ip */
          $ip_count[$current_ip]--;
    
          /* if there is no more domains on this ip, remove it from the list */
          if($ip_count[$current_ip] == 0)
          {
             unset($ip_count[$current_ip]);
          }
       }
    
       /* add current batch to the list of batches */
       $batches[] = $current_batch;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've posted this before, but I worded it poorly. I'm trying again with a
I've seen this question posted here previously but I'm not satisfied that I understand
I know this question has been posted before... but I haven't found any answer
I posted a related but still different question regarding Protobuf-Net before, so here goes:
Note this question was originally posted in 2009, before C++11 was ratified and before
I am sure that the answer to this has been posted before. Forgive me
Sorry to post another question that is similar to the question that I posted
Stumped here. Posted a similar question before. We have a pretty large WPF app
I posted a similar question before, which worked in C# (thanks to the community),
Edit at bottom with solution I've seen a similar question to this posted before

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.