I have two arrays in my PHP like following:
$brandListAll = $this->getBrandModel()->brandList();
$brandListUserRegistered = $this->getBrandUserModel()->getUserBrands($userId);
for($i=0; $i<count($brandListAll);$i++)
{
}
$brandListAll
returns all of the items from my table, which can be lets say sized of 70, while brandListUserRegistered can be sized of 2 for instance. What I'm trying to achieve is to add the items to $brandListUserRegistered
that are present in $brandListAll
.
So if brandListUserRegistered is = 2
and $brandListAll is 70;
I wanna add 68 items frmo brandListall that are missing in $brandListUserRegistered;
can someone help me out with this?
Edit:
The array $brandListUserRegistered
looks like this:
[{
"id":"64",
"brandId":"64",
"userId":"2869",
"points":"0",
"lifePoints":"0",
"days":"1",
"lifeDays":"1",
"level":"0",
"active":"1",
"joinTime":"2016-06-06 12:42:08",
"lastSignInTime":null,
"lastSignInIp":null,
"missions":null,
"vipCode":null,
"col1":null,
"col2":null,
"col3":null,
"col4":null,
"col5":null,
"name":"brand1"
}]
The array $brandListAll
looks like this:
[{
"id":"1",
"name":"brand2",
"icon":"brand_552cde1109944.png",
"owner":"1",
"slogan":"Award-winning marketing building brands with consumers ! WOW",
"banner":"brand_552ce25ba80e7.png",
"homepage":"http:\/\/mdev.advocacy.asia",
"active":"1",
"cover":"brand_552ce25fd2492.png",
"startDate":"2015-04-10",
"appId":"1",
"createTime":"2015-04-14 11:48:43",
"endDate":"2016-06-30",
"State":"Completed"
}
The array #1 contains information of userId
which array #2 doesn't have...
But I still need them merged (excluding the elements that are already with the same ID in Array #1 like in Array #2)...