How do I compare two arrays and list common items in a third array. I want to print the third array. Please help guys. My results are coming in two lists.
<?php $appsubjects = $this->ProgrammeChoice-> ApplicantsDetail->ApplicantAlevelQualification-> find('list',array('fields'=> array('subject_code'), 'conditions'=>array('ApplicantAlevelQualification.applicants_detail_id'=>$app_id))); $progrequirements = $this->ProgrammeChoice->Programme->ProgrammeRequirementsSubject-> find('all',array('fields'= > array('programme_code','subject_code','programme_name','compulsory'), 'conditions'=> array('subject_code'=>$s_code,'compulsory'=>'true'))); ?>
So now i don't know how to get a 3rd list of items for which the
subject_code is the same for Array(1) and Array(2), where
compulsory is true.
The essence of my program is that I want applicants to enter their subjects, applying for different degree programs. Then for each degree there are subjects which are required(Array(2)), and some are compulsory. So my program should be able to list all degree programmes that matches the subjects entered. I hope you understand my question. Please help i'm stuck.
If I understood, I think you are doing it wrong. You make two database queries and after that you want find common items. How about doing it directly in query? :) is there some good reason not to?
edit: or make third query after user has submitted something. some ajax and voilá.