Jump to content

[SOLVED] concatenate two arrays.


simpli

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.