Set::combine() transforms your original array into
Array
(
[path1] => [path2]
...
)
so $combine = Set::combine($this->data,'{n}.{n}.Tree.id','{n}.
{n}.Tree.name');
would result in
Array
(
[1] => Pine,
[2] => Birch,
[24] => Cherrywood
...
)
Which is nothing like what you originally indicated you wanted.
Try (not tested):
$combine = array('Tree' => Set::combine($this->data, '{n}.{n}', '{n}.
{n}.Tree');
If that doesn't generate the array the way you need, can you provide a
sample of before and after arrays with at least three elements so I/we
can better understand what you are trying to convert from and to?
On Mar 10, 11:46 pm, OldWest <[email protected]> wrote:
> I have been attempting to structure an array using the
> set::combine<http://book.cakephp.org/view/1492/combine> method,
> and I cannot get it working (what am I doing wrong!).
>
> And I will note I need to turn this into an associative array like:
>
> [Tree] => Array
> (
> [id] => 1
> [name] => Pine
> )...
>
> Here is an example of my Array:
>
> Array
> (
> [1] => Array
> (
> [1] => Array
> (
> [Tree] => Array
> (
> [id] => 1
> [name] => Pine
> )
>
> )
>
> )...
>
> And here is my set::combine call:
>
> $combine = Set::combine($this->data,'{n}.Tree.id','{n}.Tree.name');
> debug($combine);
>
> And here is the debug output of $combine:
>
> Array
> (
> [] =>
> )
>
> I can do:
>
> $combine = Set::combine($this->data,'{n}.{n}.Tree.id','{n}.{n}.Tree.name');
>
> But I still get the numeric index!
>
> Array
> (
> [Array] => Array
> (
> [0] => Oak nnn
> )
>
> )
>
> I've tried every example and have been over the manual section on combine
> all evening. Can't get this working : (
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php