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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:26:42+00:00 2026-06-06T18:26:42+00:00

I have an double level array. On the first level there are about 10

  • 0

I have an double level array.
On the first level there are about 10 indexes.
These contain each to a 275 element array which each contains a word.

Array
(
[0] => Array
    (
    [0] => Suspendisse
    [1] => Nam.
    [2] => Amet
    [3] => amet
    [4] => urna
    [5] => condimentum
    [6] => Vestibulum
    [7] => sem
    [8] => at
    [9] => Curabitur
    [10] => lorem
    .... to [275]
    )
[1] => Array
    (
    ... you get the idea
    )
... 10 elements total
)

Now, through circumstances, like an added image that takes up space, I sometimes need to recalculate the number of words that are remaining and redistribute the array that still remains.

For that I have written the below function to make the remaining array one big long array of words, that I can array_chunk then to the right proportions.
&$array is the reference to the “mother array”, $memory is an array of words that are surplus, $index is where we are iterating through a for loop, $limit is “array” length for the 2nd level, in this case 275

function redistribute(&$array,$memory,$index,$limit)
{
$ret[] = $array[0];
// skip past the current processed items
for($c=1;$c<$index;$c++)
    {
    $ret[] = $array[$c];
    }
// apply current item
$ret[] = $array[$index];

//join the rest into one big array off words;
$r2=$memory;
$length = count($array);
for($c=$index+1;$c<$length;++$c)
    {
    array_merge($r2,$array[$c]);
    print_r($r2);
    }
}

The question

array_merge(arr1,arr2) doesn’t seem to work.

when executing

redistribute($splitupchunk,array('test','test2','test3','test4'),$i,275);

print_r($r2) just prints test numbers without the extra variables from $array[$c].
How do I fix 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-06-06T18:26:45+00:00Added an answer on June 6, 2026 at 6:26 pm

    I found the reason why it didn’t work.
    I assumed that array_merge worked by reference instead of by return.

    By making the line

    array_merge($r2,$array[$c]);
    
    $r2 = array_merge($r2,$array[$c]);
    

    It now works as expected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my project directory, top level, I have Icon.png. Double-checked in Photoshop, it's 57x57.
I have double values which I would like to convert to String values with
I'm looking to slice a two dimensional array in C#. I have double[2,2] prices
I have an double array alist[1][1]=-1 alist2=[] for x in xrange(10): alist2.append(alist[x]) alist2[1][1]=15 print
I have a method like this: private static double ComputePercentage(ushort level, ushort capacity) {
I declare these two doubles at class level. private double interval = 2; private
I have an UIViewController which contains a UITableView (subclassed) and another UIView (subclassed). They
Let’s say I have double length that can be either a real length or
Right now I have double numba = 5212.6312 String.Format({0:C}, Convert.ToInt32(numba) ) This will give
I have a specific requirement that all children of a particular JComponent have double

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.