Skip to content

Instantly share code, notes, and snippets.

@arto-heino
Created June 7, 2017 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arto-heino/b136f78bf86cd1d0ba70e1f74c19e973 to your computer and use it in GitHub Desktop.
Save arto-heino/b136f78bf86cd1d0ba70e1f74c19e973 to your computer and use it in GitHub Desktop.
kysymykset_vasgtaukset
for($i=0;$i<count($kysymykset);$i++){
if(count($vastaukset) > 0){
foreach($vastaukset as $key){
if ($kysymykset[$i]['TherapygroupQuestions']['id'] == $key['TherapygroupAnswers']['question_id']) {
$kysymykset_vastaukset[$i] = array_merge($kysymykset[$i]['TherapygroupQuestions'], array('vastaus' => $key['TherapygroupAnswers']['vastaus'], 'vastaus_id' => $key['TherapygroupAnswers']['id']));
}
}
}else{
$kysymykset_vastaukset[$i] = array_merge($kysymykset[$i]['TherapygroupQuestions']);
}
}
@arto-heino
Copy link
Author

arto-heino commented Jun 9, 2017

foreach ($kysymykset as $key_kys => $value_kys) {
                if(count($vastaukset) > 0){
                    foreach($vastaukset as $key){
                        if ($value_kys['TherapygroupQuestions']['id'] == $key['TherapygroupAnswers']['question_id']) {
                            $kysymykset_vastaukset[$i] = array_merge($value_kys['TherapygroupQuestions'], array('vastaus' => $key['TherapygroupAnswers']['vastaus'], 'vastaus_id' => $key['TherapygroupAnswers']['id']));
                            $i++;
                        }
                    }
                }else{
                    $kysymykset_vastaukset[$i] = array_merge($value_kys['TherapygroupQuestions']);
                    $i++;
                }
            }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment