Re: [PHP] Recursive function for array task?

2007-04-27 Thread Stewart Macdonald
Thanks! I don't understand how it works, but it does! That's the main thing! I've been pulling my hair out over this for the last two days. You're a legend! Thanks again, Stewart On 27/04/2007, at 8:28:41 PM, [EMAIL PROTECTED] wrote: First versions got a bug, i did not merged the groups w

Re: [PHP] Recursive function for array task?

2007-04-27 Thread [EMAIL PROTECTED]
First versions got a bug, i did not merged the groups when found a pair which should connect them. This one is better: array('X'), "C" => array('Q','K'), "D" => array('M'), "F" => array('V'), "G" => array('N'), "I" => array('X','M'), "K" => array('C'), "M" => array(

Re: [PHP] Recursive function for array task?

2007-04-27 Thread Stewart Macdonald
On 27/04/2007, at 7:57:45 PM, Edward Kay wrote: Interesting problem. I've got a few ideas but please could you clarify what you want as the output? Is it just an array of the groups, i.e. Array ( [0] => 'B,X,I,M,V,F,D' [1] => 'C,Q,K' [2] => 'G,N' [3] => 'R,U' )

Re: [PHP] Recursive function for array task?

2007-04-27 Thread [EMAIL PROTECTED]
What you want is strange... but this is the solution array('X'), "C" => array('Q','K'), "D" => array('M'), "F" => array('V'), "G" => array('N'), "I" => array('X','M'), "K" => array('C'), "M" => array('I','V'), "Q" => array('C'), "R" => array('U'), "V" =>

RE: [PHP] Recursive function for array task?

2007-04-27 Thread Edward Kay
> -Original Message- > From: Stewart Macdonald [mailto:[EMAIL PROTECTED] > Sent: 27 April 2007 10:13 > To: php-general@lists.php.net > Subject: [PHP] Recursive function for array task? > > > Hi all, > > I've got a bit of a logic problem that I can&

[PHP] Recursive function for array task?

2007-04-27 Thread Stewart Macdonald
Hi all, I've got a bit of a logic problem that I can't figure out. I've got an array: Array ( [B] => X [C] => Q,K [D] => M [F] => V [G] => N [I] => X,M [K] => C [M] => I,V [Q] => C [R] => U [V] => M [X] => I ) This array shows groupings of object