<?php $policies = array ( 'TerLifIns' => array ( 0 => array ( 'company' => 'NIA', 'type' => 'Term Life Insurance', 'no' => '67845678', 'issueDate' => '2016-09-10', 'used' => 'yes', 'group' => 'Group', 'owner' => 'OWNER', 'premium' => '55', 'paymentFrequency' => 'miesięcznie', 'coverBasis' => 'Dual Life', 'lifeInsured' => 'Chester Tester, Mary Testerowa', 'indexation' => 'Yes', 'term' => '15', 'seriousIllness' => 'Standalone', 'conversion' => 'Yes', 'lifeCoverMark' => 170, 'seriousIllnessMark' => 70, 'hospitalCoverMark' => 161, 'accidentCoverMark' => 201, 'surgeryMark' => 1, 'fractureMark' => 1, 'lifecoverBasisMark' => 0, 'primary' => array ( 'lifeCover' => '85,000', 'seriousIllness' => '35,000', 'cancerCover' => '0', 'hospitalCover' => '80', 'accidentCover' => '100', 'fracture' => 'Yes', 'surgery' => 'Yes', ), 'secondary' => array ( 'lifeCover' => '85,001', 'seriousIllness' => '35,001', 'cancerCover' => '0', 'hospitalCover' => '81', 'accidentCover' => '101', 'fracture' => 'Yes', 'surgery' => 'No', ), 'DOC' => array ( 'sictypedis' => 'Opis sictypedis dla NIA.', 'lifedis' => 'Opis life dla NIA.', 'sicdis' => 'Opis sic dla NIA.', 'hospitaldis' => 'Opis hospital dla NIA.', 'accidentdis' => 'Opis acc dla NIA.', 'surgerydis' => 'Opis surg dla NIA.', 'fracturedis' => 'Opis fra dla NIA.', 'indexationdis' => 'Opis index dla NIA.', 'conversiondis' => 'Opis conver dla NIA.', 'companydis' => array ( 0 => 'Opis 0 dla NIA.', 1 => 'Opis 1 dla NIA.', 2 => 'Opis 2 dla NIA.', ), 'companyaddress' => array ( 'name' => 'NIA ', 'street' => 'street NIA', 'area' => 'area NIA', 'county' => 'county NIA', 'zipcode' => 'zip NIA', ), 'otherdefault' => 'x', ), ), 1 => array ( 'company' => 'IL', 'type' => 'Term Life Insurance', 'no' => '12345678', 'issueDate' => '2016-09-10', 'used' => 'yes', 'group' => 'Group', 'owner' => 'OWNER', 'premium' => '25', 'paymentFrequency' => 'miesięcznie', 'coverBasis' => 'Dual Life', 'lifeInsured' => 'Chester Tester, Mary Testerowa', 'indexation' => 'Yes', 'term' => '23', 'seriousIllness' => 'Accelerated', 'conversion' => 'Yes', 'lifeCoverMark' => 400, 'seriousIllnessMark' => 200, 'hospitalCoverMark' => 201, 'accidentCoverMark' => 241, 'surgeryMark' => 0, 'fractureMark' => 0, 'lifecoverBasisMark' => 0, 'primary' => array ( 'lifeCover' => '200,000', 'seriousIllness' => '100,000', 'cancerCover' => '0', 'hospitalCover' => '100', 'accidentCover' => '120', 'fracture' => '', 'surgery' => '', ), 'secondary' => array ( 'lifeCover' => '200,001', 'seriousIllness' => '100,001', 'cancerCover' => '0', 'hospitalCover' => '101', 'accidentCover' => '121', 'fracture' => '', 'surgery' => '', ), 'DOC' => array ( 'sictypedis' => 'Opis sictypedis dla IL.', 'lifedis' => 'Opis life dla IL.', 'sicdis' => 'Opis sic dla IL.', 'hospitaldis' => 'Opis hospital dla IL.', 'accidentdis' => 'Opis acc dla IL.', 'surgerydis' => 'Opis surg dla IL.', 'fracturedis' => 'Opis fra dla IL.', 'indexationdis' => 'Opis index dla IL.', 'conversiondis' => 'Opis conver dla IL.', 'companydis' => array ( 0 => 'Opis 0 dla IL.', 1 => 'Opis 1 dla IL.', 2 => 'Opis 2 dla IL.', ), 'companyaddress' => array ( 'name' => 'IL ', 'street' => 'street IL', 'area' => 'area IL', 'county' => 'county IL', 'zipcode' => 'zip IL', ), 'otherdefault' => 'x', ), ), ), 'MorIns' => array ( ), 'WOL' => array ( ), 'IncIns' => array ( ), 'AccSicAndHos' => array ( ), 'MedCas' => array ( ), 'PerAcc' => array ( ), 'SovIncAssPla' => array ( ) ); // echo ('<pre>'); // print_r($policies); // echo ('</pre>'); ?>
Na podstawie tej tabli tworze kolejną jak poniżej.
function getRecomendationTerLifInsData($policies) { //listuj wszystkie discription dla wszystkich typów i wszystkich polisy foreach ($policies as $type => &$policieType) { if($type == 'TerLifIns') { foreach ($policieType as &$policie) { for($n=0; $n<$count; $n++){ if($policie['lifeCoverMark']){$recomend[] = array('Kwota dla primary to €'.$policies['TerLifIns'][$n]['primary']['lifeCover'].', natomiast kwota dla drugiego ubezpieczonego to €'.$policies['TerLifIns'][$n]['secondary']['lifeCover'].'');} if($policie['seriousIllnessMark']){$recomend[] = array('SIC dla pierwszego to €'.$policies['TerLifIns'][$n]['primary']['seriousIllness'].', natomiast suma SIC dla drugiego to €'.$policies['TerLifIns'][$n]['secondary']['seriousIllness'].' na okres '.$policies['TerLifIns'][$n]['term'].' lat.'.$policies['TerLifIns'][$n]['DOC']['sictypedis'].'');} if($policie['hospitalCoverMark']){$recomend[] = array('Szpital dla pierwszego to €'.$policies['TerLifIns'][$n]['primary']['hospitalCover'].' za dzień pobytu dla pierwszego, a dla drugego €'.$policies['TerLifIns'][$n]['secondary']['hospitalCover'].'');} if($policie['accidentCoverMark']){$recomend[] = array('Acc dla pierwszego to €'.$policies['TerLifIns'][$n]['primary']['accidentCover'].' a dla drugiego Acc to €'.$policies['TerLifIns'][$n]['secondary']['accidentCover'].'');} if($policie['surgeryMark']){$recomend[] = array('Sur opis. '.$policies['TerLifIns'][$n]['DOC']['surgerydis'].'');} } // $recomend[] = array('----'); // foreach ($policie['DOC'] as $value) { // if(!is_array($value)){ // $recomend[] = array($value); // } // } // foreach ($policie['DOC']['companydis'] as $value) { // $recomend[] = array($value); // } // $recomend[] = array('----'); // spacer for statement of suitability } } } return $recomend; } $output = getRecomendationTerLifInsData($policies);
Problem z jakim nie wiem jak sobie poradzić to niepotrzebne wyświetlenie jednej z pętli.
Nie wiem czy jest to widoczne ale chodzi o niepotrzebne wywołanie tej pętli
foreach ($policieType as &$policie) { for($n=0; $n<$count; $n++){
Nie wiem jak to prawidłowo zapisać.
Dziękuję tradycyjnie za wyrozumiałość i pomoc.