I love the Set class:

$result = Set::combine($arrayData, array('disponible',
'PermissionGroup.{n}.id'), 'PermissionGroup.{n}.numero_horas',
'PermissionGroup.{n}.id');



On Apr 11, 3:36 pm, "Dardo Sordi Bogado" <[EMAIL PROTECTED]> wrote:
> >  How can I do it?
>
> >  I think I could use Set::combine function. I have tried this way:
>
> >  $newArray = Set::combine($arrayData, 'PermissionGroup.{n}.id',
> >  'PermissionGroup.{n}.numero_horas');
>
> >  But this creates this array:
>
> This should work:
>
> $ids = Set::extract($arrayData, 'PermissionGroup.{n}.id');
> $horas = Set::extract($arrayData, 'PermissionGroup.{n}.numero_horas');
>
> // didn't test but I think 'callback_idsHoras' could be anonymous
> (using create_function), if you use an object then use array($obj,
> 'method')
> $result = array_map( 'callback_idsHoras', $ids, $horas  );
>
> where callback_idsHoras is a function like this:
>
> function callback_idsHoras($id, $horas) {
>     return array($id => array('disponible' => $horas));
>
> }
>
> >  Array
> >  (
> >     [5] => 10
> >     [10] => 7
> >     [15] => 19
> >  )
>
> >  Thanks for your help!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to