simpli Posted June 14, 2009 Share Posted June 14, 2009 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 More sharing options...
trq Posted June 14, 2009 Share Posted June 14, 2009 Take a look at array_merge Link to comment https://forums.phpfreaks.com/topic/162123-solved-concatenate-two-arrays/#findComment-855523 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.