Hi,
here are two ways:
$test=array;
foreach($posts as $p){
if ($p['Post']['parent_id']==$post_id){
array_push($test, $p);
// or
$test[] = $p;
}
}
Michael
albe schrieb:
> I know it may be a banal question, but I couldn't find the answer
> anywhere.
> How can I add elements to an array in a cycle like this:
>
> $test=array;
>
> foreach($posts as $p){
> if ($p['Post']['parent_id']==$post_id){
>
> put $p into the array $test.... how can I do it?
>
> }
> }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---