Link to home
Start Free TrialLog in
Avatar of tjyoung
tjyoung

asked on

Problem stepping through nested array

Im having trouble iterating through this nested array.

I cant seem to figure out how to reference the groups[] first value for each row. I'm trying to insert it into the GroupID column. For example the '2125a02a-f28e-11e4-ad33-89d58f4ed955' in the first one below would be the first GroupID

Looks like:

groups[2125a02a-f28e-11e4-ad33-89d58f4ed955]
0	4ec28c6a-6294-5329-fe01-57dc3228e4c2
1	a6a1f81f-33f1-79d8-3f61-5c8fb5e27e16

groups[24cd7e3c-f28e-11e4-ad33-89d58f4ed955]
0	4ec28c6a-6294-5329-fe01-57dc3228e4c2
1	364a7c59-da10-567d-268d-57dc323de111

groups[3efd3a5e-f28e-11e4-ad33-89d58f4ed955]
0	4e666186-4c18-eb53-c36a-5cebf8286305
1	4ec28c6a-6294-5329-fe01-57dc3228e4c2
2	a6a1f81f-33f1-79d8-3f61-5c8fb5e27e16

Open in new window


I'm iterating through it like:
foreach($groups as $group)
		{
			foreach($group AS $rep)
			{
				DB::table('connect_teams')->insert([
				'dealer_id'	=> $dealer_id,
				'UserId'	=> $rep,
				'GroupId'	=> how to get the $groups[currentvalue]??
				]);
		
			}
		}

Open in new window

any help would be much appreciated
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tjyoung
tjyoung

ASKER

Thanks as always. Saved me much hassle.
No worries :)