On Mon, May 17, 2010 at 9:13 AM, Richard Quadling
wrote:
> OOI, can you take a look at my first response. Is this the sort of
> thing you were talking about?
>
Essentially, yes. For the temporary array I would map nid => element instead
of INDEX => nid. Your $Relationships array is basically the
On 17 May 2010 16:41, David Harkness wrote:
> Shahrzad,
>
> While your algorithm is correct it is very inefficient. The full array is
> scanned for every element in the array. If the array contains 1,000
> elements, 1,000,000 comparisons will be performed and mktree_array() will be
> called 1,000
Shahrzad,
While your algorithm is correct it is very inefficient. The full array is
scanned for every element in the array. If the array contains 1,000
elements, 1,000,000 comparisons will be performed and mktree_array() will be
called 1,000 times. This is known as order n squared: O(n^2) and is a
Thanks to all, it works now:
function mktree_array(&$arr, $id = 0)
{
$result = array();
foreach ($arr as $a) {
if ($id == $a['parentID']) {
$a['children'] = $this->mktree_array($arr, $a['nid']);
$result[] = $a;
}
}
On 13 May 2010 11:42, shahrzad khorrami wrote:
>
> Dear Richard,
> we have more than one parentIDÂ with value 0 in main array, your
> code is so good but show me just the children of first parentID 0.
>
> :)
>
> Thanks,
> Shahrzad
>
print_r($Data[0]['children']);
maybe.
--
-
Richa
Dear Richard,
we have more than one parentID with value 0 in main array, your
code is so good but show me just the children of first parentID 0.
:)
Thanks,
Shahrzad
Thanks Rechard :) I'm testing it... merccc
On 13 May 2010 11:09, Richard Quadling wrote:
> On 13 May 2010 09:51, shahrzad khorrami wrote:
>> hi all,
>>
>> I want to create an array from another array to create json file in my
>> format and pass it to a js libraryok.
>> I just know that I have to use recursive function... but how? it's
On 13 May 2010 09:51, shahrzad khorrami wrote:
> hi all,
>
> I want to create an array from another array to create json file in my
> format and pass it to a js libraryok.
> I just know that I have to use recursive function... but how? it's hard for
> me to create the new array..
Assuming tha
9 matches
Mail list logo