The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Merging 2 Arrays
I have 2 arrays, I want to merge them on the common intersect.
Here they are... Code:
Array ( [0] => Array ( [countm] => 16 [percentage] => 84.2% [gamename] => Battlefield 2 ) [1] => Array ( [countm] => 1 [percentage] => 5.3% [gamename] => Call of Duty ) [2] => Array ( [countm] => 0 [percentage] => 0% [gamename] => Command & Conquer ) [3] => Array ( [countm] => 17 [percentage] => 89.5% [gamename] => Counter Strike ) [4] => Array ( [countm] => 0 [percentage] => 0% [gamename] => Counter Strike- Condition Zero ) [5] => Array ( [countm] => 1 [percentage] => 5.3% [gamename] => Counter Strike- Source ) [6] => Array ( [countm] => 4 [percentage] => 21.1% [gamename] => Day of Defeat ) [7] => Array ( [countm] => 0 [percentage] => 0% [gamename] => Diablo II ) [8] => Array ( [countm] => 6 [percentage] => 31.6% [gamename] => Diablo II- Lord of Destruction ) [9] => Array ( [countm] => 0 [percentage] => 0% [gamename] => Final Fantasy XI ) [10] => Array ( [countm] => 0 [percentage] => 0% [gamename] => Gun Bound ) [11] => Array ( [countm] => 2 [percentage] => 10.5% [gamename] => Maple Story ) [12] => Array ( [countm] => 0 [percentage] => 0% [gamename] => Rune Scape ) [13] => Array ( [countm] => 0 [percentage] => 0% [gamename] => Soldat ) [14] => Array ( [countm] => 2 [percentage] => 10.5% [gamename] => StarCraft ) [15] => Array ( [countm] => 4 [percentage] => 21.1% [gamename] => StarCraft- Brood War ) [16] => Array ( [countm] => 0 [percentage] => 0% [gamename] => WarCraft III ) [17] => Array ( [countm] => 1 [percentage] => 5.3% [gamename] => WarCraft III- Frozen Throne ) [18] => Array ( [countm] => 4 [percentage] => 21.1% [gamename] => World of Warcraft ) ) Array ( [0] => Array ( [countc] => 8 [gamename] => Battlefield 2 ) [1] => Array ( [countc] => 8 [gamename] => Call of Duty ) [2] => Array ( [countc] => 5 [gamename] => Command & Conquer ) [3] => Array ( [countc] => 25 [gamename] => Counter Strike ) [4] => Array ( [countc] => 8 [gamename] => Counter Strike- Condition Zero ) [5] => Array ( [countc] => 12 [gamename] => Counter Strike- Source ) [6] => Array ( [countc] => 17 [gamename] => Day of Defeat ) [7] => Array ( [countc] => 7 [gamename] => Diablo II ) [8] => Array ( [countc] => 15 [gamename] => Diablo II- Lord of Destruction ) [9] => Array ( [countc] => 9 [gamename] => Gun Bound ) [10] => Array ( [countc] => 7 [gamename] => Maple Story ) [11] => Array ( [countc] => 5 [gamename] => Rune Scape ) [12] => Array ( [countc] => 10 [gamename] => Soldat ) [13] => Array ( [countc] => 15 [gamename] => StarCraft ) [14] => Array ( [countc] => 3 [gamename] => StarCraft- Brood War ) [15] => Array ( [countc] => 5 [gamename] => WarCraft III ) [16] => Array ( [countc] => 8 [gamename] => WarCraft III- Frozen Throne ) [17] => Array ( [countc] => 8 [gamename] => World of Warcraft ) ) countc, countm, gamename, and percentage (in the same format as it is now, just one array instead of 2). I tried using nested foreachs using IFs to create a new array, but had no luck, it just got really messy. Any help would be greatly appreciated. If it is something extremely simple, I apologize, I was up way too last last night working on this. :ermm: |
#2
|
|||
|
|||
Have a look at 'array_merge'
|
#3
|
||||
|
||||
That just adds the second one to the end of the first. I need it kind of like a left join in MySQL. Both have a common field, combine resultset with only one of the common field.
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|