Recursive function to relate one array to another

0

My problem is this. I have two tables in my database, patients and diseases.

Table patients have the columns named patient, (symptom 1, symptom 2, .... symptom n). The symptoms are fed with values between 0 and 1. For they are fuzzy logic values.

The Diseases Table is a knowledge base, where they have the fields of diseaseName (symptom 1, symptom 2, .... symptom n). The symptoms are fed with values between 0 and 1. For they are fuzzy logic values.

It is necessary to scan these two tables, and then generate a new one.

Example: Relation between table patients (patient name, symptom 1) x table diseases (disease name, symptom1). From this relationship it is necessary to take the lowest value. That is. If (patient name, symptom 1) = 1 and (disease name, symptom1) = 0.45. The value returned from the scan will be 0.45.

With the code below I can do this, but I need to apply recursion, and not use for, s outside of a recursive function.

//Pega repete a analise somente para o paciente corrente, ou seja 1.
for ($p=0; $p < 1; $p++) { 
    //Inicializa o arrey.
    $_max = array();
    //Pega todas as doenças registradas no banco para análise.
    for ($d = 0; $d < count($doencas); $d++) {
        //Inicializa o arrey.
        $_min = array();
        //Pega todos os sitomas registrados no banco para análise.
        for ($i=1; $i < count($sintomas)+1; $i++) { 
            //Cria um array com as relações (sintomas x doença) e (sintomas x paciente), e gera o valor mínimo de cada uma.
            array_push($_min, min($doencas[$d]['ap'.$i],$pacientes[$p]['ap'.$i]));      
        }
    //Recebe o valor mínimo da relação, para cada doença.
    $valor = max($_min);
    //Gera um array com o valor máximo, da relação dos mínimos.
    array_push($_max, $valor.' - '.$doencas[$d]['profissao']);

    };
};
    
asked by anonymous 23.10.2017 / 19:16

0 answers