Jump to content

Recommended Posts

Hi,

I am having trouble concatenating arrays. It's just not working. I have the following code:

$rootItems = array();

foreach ($scenarios as $scenario) {
$rootItems[] = $_treePath->getImmediateDescendants($scenario["node_id"]);
}

getImmediateDescendants returns an associative array as a result.

When I get out of the loop, I expect $rooItems to hold an associative array that is the concatenation. For example if I have scenarios 1 and 2, I expect $rootItems to hold the cumulative information of the two scenarios. I was expecting an operation like $rootItems = rootItems +  $_treePath->getImmediateDescendants($scenario["node_id"]); to allow me to do that but the documentation seems to be saying otherwise.

 

I'm using php5 with a mysql database I'm pulling information from.

 

Anyone can help?

 

Thanks,

JR

 

Link to comment
https://forums.phpfreaks.com/topic/162123-solved-concatenate-two-arrays/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.