0





59

Advertisement

I have the following arrays named investmentprogramscriteria and companyInvestmentProfil:

Array
(
[0] => Array
    (
        [investmentprogramcriteriaID] => 20
        [investmentprogramID] => 21
        [criteriaID] => 59
        [criteriaIsMatchedIf] => 1
    )[1] => Array
    (
        [investmentprogramcriteriaID] => 21
        [investmentprogramID] => 21
        [criteriaID] => 57
        [criteriaIsMatchedIf] => 1
    ))
Array
(
[0] => Array
    (
        [investmentprofileID] => 1
        [companyID] => 27
        [criteriaID] => 54
        [investmentprofileCriteriaAnswer] => 1
    )[1] => Array
    (
        [investmentprofileID] => 2
        [companyID] => 27
        [criteriaID] => 57
        [investmentprofileCriteriaAnswer] => 0
    )[2] => Array
    (
        [investmentprofileID] => 3
        [companyID] => 27
        [criteriaID] => 58
        [investmentprofileCriteriaAnswer] => 0
    )[3] => Array
    (
        [investmentprofileID] => 4
        [companyID] => 27
        [criteriaID] => 59
        [investmentprofileCriteriaAnswer] => 1
    ))

If the last 2 KEYS AND THEIR VALUES from the first array are found in the second array, code should return match, else should return not match.

I make an attempt to resolve this with array functions, but nothing worked and now I am trying to solve it with php, but no luck so far.

I am trying with:

foreach ($investmentprogramscriteria as $programcriteria) {
    //foreach($companyInvestmentProfil as $profile) {
        if (($programcriteria['criteriaID'] == $companyInvestmentProfil[$i]['criteriaID']) && ($programcriteria['criteriaIsMatchedIf'] == $companyInvestmentProfil[$i]['investmentprofileCriteriaAnswer']))  {
        $match = "Match";                              
    } else {
       $match = "Not Match";
       continue;
// }                                
}                        }
Question author User2417624 | Source

Advertisement


0


The best way is use foreach twice !!!

foreach ($investmentprogramscriteria  as $value) {    foreach ($companyInvestmentProfil as $v) {        if($v["criteriaID"] == $value["criteriaID"]) echo "match<br>";        else echo "not Match<br>";    }    }
Answer author David-jorhpan