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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:21:36+00:00 2026-05-25T00:21:36+00:00

ok, so i been on a mental struggle here trying to get this completed.

  • 0

ok, so i been on a mental struggle here trying to get this completed.

I have an array that looks like

Array ( [0] => cluster_1 [1] => cluster_2 )

I want to add a new user to the first available cluster that has sufficient space to allocated the new user.

I have this class method created to output the amount of megs in each array item. I can test it out and echo the results with

foreach ($cluster_array as $cluster) {
    echo $cluster . " " . Server::server_free_space("/agents/" . $cluster, 2)."<br />";
}

the output gives me

cluster_1 20505
cluster_2 21398

those figures are in MB.

I want to have my array looped to find the first available cluster that has enough space to allocate a new user. For example if a new user needs 1gb allocated, thats 1024mb. So if the first cluster in the array does not have 1024MB free, then it will move and scan the next cluster in the array and so on. Adding the user to that cluster.

How would I approach this?

  • 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-25T00:21:36+00:00Added an answer on May 25, 2026 at 12:21 am

    Shouldn’t it be just:

    foreach ($cluster_array as $cluster) {
        $size =  Server::server_free_space("/agents/" . $cluster, 2);
        if($size >= $whatTheUserNeeds) {
            // add user to cluster
            break;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a mental excercise that has been bothering me for a while. What
I have been trying to understand and get something working with dependency properties. I
I have been stuck on this problem for quite awhile... I hope someone out
I've been trying all day to get a way to authenticate via a simple
I'm having a period mental melt down here. For 2 days, I've been looking
I have hit a mental wall. Basically, this code is supposed to execute and
Been toying with this for some time... I have an xml file with the
Been a while since I've used C++. Can I do something like this?: for
I've been trying to create a custom renderer based on this Yehuda Katz's blog
Been staring at this problem for a while now. Here's the error I'm getting

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.