Thursday, March 14, 2013

Re: How to campare two arrays whether they have the same elements-cakephp 1.3

In fact, the question is that, I am responsible for managing a education website, the website will supply courses for each quarter, 
the courses supplied for each quarter maybe same, but the students won't be allowed to choose the courses which the students have choose before.
Now I can get the courses the students have chosen before.
foreach($registered as $value){
     echo  $value['Listing']['title'];
   }

and here is the course supplied for the current quarter.
foreach($courseListings as $listing){ 
  echo  $listing['Listing']['title'];
   }
so if some courses were chosen by the student before, he won't be allowed to choose the course for the current quarter.
Below is the form for courses register.
                                <tr>
  <td width="24%">Enroll in course :</td>
  <td width="42%">
  <?php echo $form->create('Registration',array('action'=>'index')); ?>
<?php echo $form->input('listing',array('label'=>false,'div'=>false)); ?>
</td>
  <td width="34%"><?php echo $form->end('Enrol') ?></td>
</tr>
I tried but didn't  figure it out.
Do you have some good ideas?
Thank you so much.

On Thu, Mar 14, 2013 at 9:22 AM, Joseph zhu <zhubujun314@gmail.com> wrote:
two array:
one is: foreach($courseListings as $listing){ 
  echo  $listing['Listing']['title'];
   }
another one:
foreach($registered as $value){
    echo  $value['Listing']['title'];
   }
How to campare them and get the same elements.
Thanks a lot.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to a topic in the Google Groups "CakePHP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/gqIqXb6j_EU/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
God bless you!
Joseph

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: