1
Bir soru kümesi ve bir üst kümenin, ana adı temelinde, sorunun yanıtını okumak ve matris gibi bir dize oluşturmak istiyorum. Sonuç tüm olasılıkların bir kombinasyonu olacaktır.Dizi değerleriyle dize oluşturma
Ben
key=524136910&CurrentInsuranceStatus=Y&InsuredTimeframe=-1
key=524136910&CurrentInsuranceStatus=Y&InsuredTimeframe=FiveYearsorMore
...
key=524136910&CurrentInsuranceStatus=Parents&InsuredTimeframe=-1
key=524136910&CurrentInsuranceStatus=Parents&InsuredTimeframe=FiveYearsorMore
Aşağıda benim kod ama dizede kendi tekrar üstüdür aşağıdaki gibi sonuç bir dize yazmak istiyorum. Örnek CurrentInsuranceStatus bu ebeveyn ve = işaretinden sonra Aşağıda
public function createCBQJson($questions,$parents)
{
$cbqStdObj = $parents;
$jsonString = '';
$urlArr = array();
foreach($cbqStdObj as $key=>$val)
{
if(!in_array($key, array('DriverOccupation')))
{
//continue;
}
$jsonString = $key;
if(isset($val->k))
{
$cbqKey = $val->k;
}
// echo 'parents of -'.$jsonString.'--<br>';
$cbqUrl = '';
if(isset($val->p) && count($val->p)>=2)
{
foreach($val->p as $pkey=>$pval)
{
//create url with parent
$answers = $questions[$pval]['QuestionData']->_answerOptions;
if(count($answers) > 0)
{
foreach($answers as $ansKey=>$ansValue)
{
$cbqUrl.= '?key='.$cbqKey.'&'.$pval.'='.$ansValue->_value ;
}
}
}
$cbqSet[$cbqKey] = $cbqUrl;
}
}
}
cevap vermek için almak için kodunun altına kullanabilirsiniz sorular Aşağıda
Array
(
[CurrentInsuranceStatus] => Array
(
[QuestionData] => Platform_Form_Page_Question Object
(
[_answer] =>
[_answerOptions] => Array
(
[0] => Platform_Form_Page_Question_AnswerOption Object
(
[_answerKey] => 340280
[_hideAnswer] =>
[_order] => 110
[_promptText] => Yes
[_value] => Y
[_errorLog] => Array
(
)
)
[1] => Platform_Form_Page_Question_AnswerOption Object
(
[_answerKey] => 340290
[_hideAnswer] =>
[_order] => 120
[_promptText] => Yes, on parents policy
[_value] => Parents
[_errorLog] => Array
(
)
)
[2] => Platform_Form_Page_Question_AnswerOption Object
(
[_answerKey] => 340300
[_hideAnswer] =>
[_order] => 130
[_promptText] => Yes, insured through employer
[_value] => Company
[_errorLog] => Array
(
)
)
[3] => Platform_Form_Page_Question_AnswerOption Object
(
[_answerKey] => 340310
[_hideAnswer] =>
[_order] => 140
[_promptText] => No, policy lapsed/expired
[_value] => Lapsed
[_errorLog] => Array
(
)
)
[4] => Platform_Form_Page_Question_AnswerOption Object
(
[_answerKey] => 340320
[_hideAnswer] =>
[_order] => 150
[_promptText] => No, never been insured
[_value] => Never
[_errorLog] => Array
(
)
)
[5] => Platform_Form_Page_Question_AnswerOption Object
(
[_answerKey] => 340330
[_hideAnswer] =>
[_order] => 160
[_promptText] => No, I didnt have a vehicle to insure
[_value] => First
[_errorLog] => Array
(
)
)
[6] => Platform_Form_Page_Question_AnswerOption Object
(
[_answerKey] => 340340
[_hideAnswer] =>
[_order] => 170
[_promptText] => No, been deployed/overseas in the military
[_value] => Military
[_errorLog] => Array
(
)
)
[7] => Platform_Form_Page_Question_AnswerOption Object
(
[_answerKey] => 340350
[_hideAnswer] =>
[_order] => 180
[_promptText] => No, other reason
[_value] => Other
[_errorLog] => Array
(
)
)
)
[_answersDivID] => html_CurrentInsuranceStatus
[_phoneAreaField] =>
[_attributeName] => CurrentInsuranceStatus
[_criteriaBasedQuestion] => 1
[_dateField] =>
[_eventHandler] =>
[_fieldType] => select
[_hideQuestion] => 1
[_monthField] =>
[_phoneNumberField] =>
[_order] => 10010
[_pageAttributes] => stdClass Object
(
[additionalLabel] =>
[answerStyle] =>
[colNum] =>
[colWidth] =>
[cssclass] =>
[defaultValue] =>
[isMultiSelect] =>
[maxLength] =>
[min] =>
[questionSkinStyle] =>
[toolTip] =>
)
[_phonePreFixField] =>
[_questionDivID] => prompt_CurrentInsuranceStatus
[_questionKey] => 7520910
[_required] => 1
[_text] => Current insurance status
[_yearField] =>
[_errorLog] => Array
(
)
)
)
[InsuredTimeframe] => Array
(
[QuestionData] => Platform_Form_Page_Question Object
(
[_answer] =>
[_answerOptions] => Array
(
[0] => Platform_Form_Page_Question_AnswerOption Object
(
[_answerKey] => 3063810
[_hideAnswer] =>
[_order] => 100
[_promptText] => Please Select
[_value] => -1
[_errorLog] => Array
(
)
)
[1] => Platform_Form_Page_Question_AnswerOption Object
(
[_answerKey] => 653710
[_hideAnswer] =>
[_order] => 110
[_promptText] => 5 years or more
[_value] => FiveYearsorMore
[_errorLog] => Array
(
)
)
[2] => Platform_Form_Page_Question_AnswerOption Object
(
[_answerKey] => 653810
[_hideAnswer] =>
[_order] => 120
[_promptText] => 4-5 years
[_value] => FourtoFiveYears
[_errorLog] => Array
(
)
)
[3] => Platform_Form_Page_Question_AnswerOption Object
(
[_answerKey] => 654110
[_hideAnswer] =>
[_order] => 130
[_promptText] => 3-4 years
[_value] => ThreetoFourYears
[_errorLog] => Array
(
)
)
[4] => Platform_Form_Page_Question_AnswerOption Object
(
[_answerKey] => 654310
[_hideAnswer] =>
[_order] => 140
[_promptText] => 2-3 years
[_value] => TwotoThreeYears
[_errorLog] => Array
(
)
)
[5] => Platform_Form_Page_Question_AnswerOption Object
(
[_answerKey] => 654210
[_hideAnswer] =>
[_order] => 150
[_promptText] => 1-2 years
[_value] => TwelveOrMoreMonths
[_errorLog] => Array
(
)
)
[6] => Platform_Form_Page_Question_AnswerOption Object
(
[_answerKey] => 654010
[_hideAnswer] =>
[_order] => 160
[_promptText] => 6 to 11 months
[_value] => SixToElevenMonths
[_errorLog] => Array
(
)
)
[7] => Platform_Form_Page_Question_AnswerOption Object
(
[_answerKey] => 653910
[_hideAnswer] =>
[_order] => 170
[_promptText] => Less than 6 months
[_value] => LessThanSixMonths
[_errorLog] => Array
(
)
)
)
[_answersDivID] => html_InsuredTimeframe
[_phoneAreaField] =>
[_attributeName] => InsuredTimeframe
[_criteriaBasedQuestion] => 1
[_dateField] =>
[_eventHandler] =>
[_fieldType] => select
[_hideQuestion] => 1
[_monthField] =>
[_phoneNumberField] =>
[_order] => 10020
[_pageAttributes] => stdClass Object
(
[additionalLabel] =>
[answerStyle] =>
[colNum] =>
[colWidth] =>
[cssclass] =>
[defaultValue] =>
[isMultiSelect] =>
[maxLength] =>
[min] =>
[questionSkinStyle] =>
[toolTip] =>
)
[_phonePreFixField] =>
[_questionDivID] => prompt_InsuredTimeframe
[_questionKey] => 7169110
[_required] => 1
[_text] => How long have you been continuously insured?
[_yearField] =>
[_errorLog] => Array
(
)
)
)
)
arrray ebeveyn dizisi
stdClass Object
(
[IncidentClaimAmountPaid] => stdClass Object
(
[o] => 13520
[k] => 524136910
[p] => Array
(
[0] => CurrentInsuranceStatus,
[1] => InsuredTimeframe
)
[e] =>
[r] => 1
[a] => Array
(
[0] => stdClass Object
(
[i] => 32
[k] => 529582210
[p] => Array
(
[0] => IncidentClaimLabel
)
[e] =>
)
[1] => stdClass Object
(
[i] => 1
[k] => 529580710
[p] => Array
(
[0] => IncidentClaimLabel
)
[e] =>
)
[2] => stdClass Object
(
[i] => 4
[k] => 529581310
[p] => Array
(
[0] => IncidentClaimLabel
)
[e] =>
)
[3] => stdClass Object
(
[i] => 2
[k] => 529581010
[p] => Array
(
[0] => IncidentClaimLabel
)
[e] =>
)
[4] => stdClass Object
(
[i] => 16
[k] => 529581910
[p] => Array
(
[0] => IncidentClaimLabel
)
[e] =>
)
[5] => stdClass Object
(
[i] => 128
[k] => 529582810
[p] => Array
(
[0] => IncidentClaimLabel
)
[e] =>
)
[6] => stdClass Object
(
[i] => 64
[k] => 529582510
[p] => Array
(
[0] => IncidentClaimLabel
)
[e] =>
)
[7] => stdClass Object
(
[i] => 256
[k] => 530551610
[p] => Array
(
[0] => IncidentClaimLabel
)
[e] =>
)
[8] => stdClass Object
(
[i] => 8
[k] => 529581610
[p] => Array
(
[0] => IncidentClaimLabel
)
[e] =>
)
)
)
)