Ich bin neu in PHP. also kann es sehr einfach sein, aber ich weiß es nicht. Also, ich möchte so in PHP mit json_encode() ausgeben.Drucken foreach Schleife mit json_encode in PHP
"option": [
{
"poOptionGroup": "11",
"optGrpID": "11",
"optGrpName": "Choose Backing Material"
},
{
"optID": "40",
"optName": "Black (Plexiglass)",
"optPriceDiff": "0"
},
{
"optID": "41",
"optName": "Clear (Plexiglass)",
"optPriceDiff": "18"
},
{
"optID": "218",
"optName": "Neon Stand Off",
"optPriceDiff": "18"
},
{
"optID": "219",
"optName": "White Plastic",
"optPriceDiff": "18"
}
],
"option": [
{
"poOptionGroup": "13",
"optGrpID": "13",
"optGrpName": "Any notes you want to include with your order"
},
{
"optID": "174",
"optName": "NO Thanks",
"optPriceDiff": "0"
},
{
"optID": "175",
"optName": "YES OUTDOOR",
"optPriceDiff": "170"
}
],
"SPIN3": [
{
"poOptionGroup": "56",
"optGrpID": "56",
"optGrpName": "Upgrade to OUTDOOR"
},
{
"optID": "44",
"optName": "",
"optPriceDiff": "20.02"
}
]
dafür habe ich zwei verschachtelte foreach-Schleife. was ist wie folgt:
$product=array();
foreach($query as $q){
$product['optGrpID']= $q['optGrpID'];
$product['optGrpName'] = $q['optGrpName'];
$product['poOptionGroup'] = $q['poOptionGroup'];
$opt_id=$product['optGrpID'];
$string= sql("select optID, optName, optPriceDiff from options where optGroup='$opt_id' ");
foreach ($string as $k=>$s){
$product['options']['optID']=$s['optID'];
$product['options']['optName']=$s['optName'];
$product['options']['optPriceDiff']=$s['optPriceDiff'];
}
}
also wie kann ich diese gewünschte leistung erreichen? bitte hilfe. Jede Hilfe wird zu schätzen wissen.
Hey @softech - Ich bin nur interessiert, ob meine Antwort für Sie hilfreich war? Brauchen Sie weitere Hilfe zu diesem Thema? –