Algorithm for grouping items in PHP Coding Help Posted June 10, 2013 · Edited June 10, 2013 by okabe Hi everyone, i have some troubles to solve this "grouping" problem. I have 2D (nxn) array and i want to group all related item to groups. Items are considered to be related in 2 cases: when they have the same edge or top. $table = array( array( 0, 0, 0, 0, 0, 0), array( 0, 0, 1, 2, 0, 0), array( 0, 0, 0, 0, 0, 0), array( 0, 3, 0, 4, 0, 0), array( 0, 0, 5, 0, 0, 0), array( 0, 0, 0, 6, 0, 7) ); And this is result which i want to achieve : $groups= array( array( 1, 2), array( 3, 4, 5, 6), array( 7 ), ); I will be grateful for any help. THX
Algorithm for grouping items
in PHP Coding Help
Posted · Edited by okabe
Hi everyone, i have some troubles to solve this "grouping" problem.
I have 2D (nxn) array and i want to group all related item to groups.
Items are considered to be related in 2 cases: when they have the same edge or top.
And this is result which i want to achieve :
I will be grateful for any help. THX