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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:45:04+00:00 2026-05-27T04:45:04+00:00

I need to fill a multidimensional array and here is my code I have

  • 0

I need to fill a multidimensional array and here is my code I have so far for it.

while($num > $i)
{
        $default[$i]=0;
        $defaultcounter=0;
        $default2[$i]=0;
        $default3[$i]=0;
        $query="Select * from `issues` WHERE `app`='" . $applist[$i] . "'" . "AND `startmonth`='". $month ."' ORDER BY `id` ASC";
        $result=mysql_query($query);
        while($row = mysql_fetch_array($result))
        {
            $downtime[$i]+=$row['duration'];
            $default2[$i]++;    //Number of Incidents Variable
            $defaultcouinter++;
            $times[$i] = array();
            $times[$i][$defaultcounter[$i]]=$row['startday'].$row['starttime'];
        }
        $appavail[$i]=100 -(ceil($downtime[$i] * 100 / $totaltime));
        $default[$i] = (ceil($downtime[$i] / $defaultcounter));
        $i++;
    }

Apparently I am not doing the array assignment correct. I need to to have my number of rows counted with the $i variable outside of my while then inside the while the defaultcounter will be keeping up with the column. I tried just doing a $time[$i][defaultcounter] and it didn’t like it. Whats the proper syntax for assigning a multidimensional array?

Thanks

  • 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-27T04:45:05+00:00Added an answer on May 27, 2026 at 4:45 am

    $times[$i] = array() should be out (before) the while loop unless you want it redefining $times as an empty array in each iteration (reseting values). Apart from that, you’re assigning the values correct, although it looks a bit odd (not sure what you want to achieve there). This are the general formulas, should give you an idea:

    $array[] = $subarray;
    $array[$subarray] = $value;
    $array[$subarray][] = $value;
    $array[$subarray][$i] = $value;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two fields that need to multiply each other and fill a third
I have a combobox in a dialog box form. I need to fill this
I need to fill a object using jQuery I have a dialog (jQueryUI) that
I have a list that I need to fill using a JSON collection of
I'm clearly missing something here. I need to fill methods of dynamic AS3 class
I have table which is filled from external application. I need to fill column
I have a wizard where users need to fill out data. You cannot navigate
I need to fill a textbox with a value by default using the autofill
i need to fill in the int[] array in C++ from zero to number
I created a lib where I need to fill a byte array of 307200

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.