@FRATEREH

Извлечение всех элементов цикла?

Где то туплю

Мне нужно что бы в $jko2 и $jko3 вывело все элементы цикла, сейчас оно выводит последний и я понимаю что он просто идет по нему и записывает конечное значение, да я понимаю что я могу это записать в пустой массив [] но не понимаю какой в этом смысл, когда мне его надо будет извлекать и по сути я приду к тому же + в jkk я не могу делать foreach потому что по сути это значение самой переменной которая далее возвращается, так же я понимаю что могу сделать прибавление .= вместо просто присвоения = но тогда оно будет каждый раз просто прибавлять инфу и в этом нет смысла особо


Спасибо за помощь!

P. S. Касаемо html я не могу встраивать куски php в него потому что я делаю это на wp и итоговую функцию вывожу в шорткод который выполняется на простой html странице без php

JSON

"data": {
"id": 7338,
"notification_id": 1272,
"member_name": "Russian Federation",
"member_code": "C643",
"document_symbol": "G\/MA\/QR\/N\/RUS\/5",
"qr_serial_number": 5,
"qr_group": 753665709,
"measures": [{
"symbol": "P",
"label": "Prohibition",
"products": [{
"hs_version": "HS-17",
"chapter": "37",
"code": "3706",
"reported_code": "ex 3706",
"description": "Cinematographic film, exposed and developed, whether or not incorporating soundtrack or consisting only of soundtrack",
"reported_description": "Printed and audiovisual products containing calls to extremist and terrorist activity or public justification of terrorism",
"interpreted": 0
}, {
"hs_version": "HS-17",
"chapter": "49",
"code": "4901",
"reported_code": "ex 4901",
"description": "Printed books, brochures and similar printed matter, whether or not in single sheets (excl. periodicals and publications which are essentially devoted to advertising)",
"reported_description": "Printed and audiovisual products containing calls to extremist and terrorist activity or public justification of terrorism",
"interpreted": 0
}] }, {
"symbol": "P-X",
"label": "Prohibition",
"products": [{
"hs_version": "HS-17",
"chapter": "37",
"code": "3706",
"reported_code": "ex 3706",
"description": "Cinematographic film, exposed and developed, whether or not incorporating soundtrack or consisting only of soundtrack",
"reported_description": "Printed and audiovisual products containing calls to extremist and terrorist activity or public justification of terrorism",
"interpreted": 0
}, {
"hs_version": "HS-17",
"chapter": "49",
"code": "4901",
"reported_code": "ex 4901",
"description": "Printed books, brochures and similar printed matter, whether or not in single sheets (excl. periodicals and publications which are essentially devoted to advertising)",
"reported_description": "Printed and audiovisual products containing calls to extremist and terrorist activity or public justification of terrorism",
"interpreted": 0
}]
}],
"administrative_mechanisms": "Administered by the Federal Customs Service",
"national_legal_bases": "Decision of the Board of the Eurasian Economic Commission \u2116 30 of April 21; 2015; as last amended and adjusted",
"description": "Import and export prohibition of printed information or information on audio-visual and other devices",
"period_from_dt": "01\/10\/2020",
"period_to_dt": "30\/09\/2022",
"in_force_dt": "01\/10\/2021",
"wto_agreements": [{
"agreement_code": "026",
"agreement_source": "GATT",
"agreement_label": "GATT 1994",
"agreement_web_link": "http:\/\/www.wto.org\/english\/docs_e\/legal_e\/gatt47_01_e.htm",
"article_code": "021802",
"article_element_code": 2,
"article_description": "XX:(a) - (a) necessary to protect public morals;",
"article_element_label": "BODY",
"article_footnote": "",
"article_index": "Article XX:(a)"
}, {
"agreement_code": "026",
"agreement_source": "GATT",
"agreement_label": "GATT 1994",
"agreement_web_link": "http:\/\/www.wto.org\/english\/docs_e\/legal_e\/gatt47_01_e.htm",
"article_code": "021904",
"article_element_code": 2,
"article_description": "XXI:(c) - (c) to prevent any contracting party from taking any action in pursuance of its obligations under the United Nations Charter for the maintenance of international peace and security.",
"article_element_label": "BODY",
"article_footnote": "",
"article_index": "Article XXI:(c)"
}],
"non_wto_agreements": []
}
}


PHP Foreach
foreach ($dfs as $dfs2){
if ($dfs2['administrative_mechanisms'][0]):
$rop = '<h4>Administrative Mechanisms</h4>'.$dfs2['administrative_mechanisms'].'';	
endif;	
foreach ($dfs2['wto_agreements'] as $dfs3):
$jko2 = '<span style="color:#fff;">Agreement Label:</span> '.$dfs3['agreement_label'].'</span><br><span style="color:#fff;">Article Code:</span> <a href="'.$dfs3['agreement_web_link'].'" target="_blank" style="color:#00aeff">'.$dfs3['article_code'].'</a></span><br><span style="color:#fff;">Article Index:</span> '.$dfs3['article_index'].'</span><br><span style="color:#fff;">Article Description:</span> '.$dfs3['article_description'].'</span></dd>';
endforeach;
foreach ($dfs2['measures'] as $dfs4){ 
$jko4 = '<span style="color:#fff;">Label:</span> '.$dfs4['label'].'<br><span style="color:#fff;">Symbol:</span> '.$dfs4['symbol'].'';
foreach ($dfs4['products'] as $dfs5){
$jko3 = '<span style="color:#fff;">HS Version:</span> '.$dfs5['hs_version'].'<br><span style="color:#fff;">Code:</span> '.$dfs5['code'].'<br><span style="color:#fff;">Description:</span> '.$dfs5['description'].'<br><span style="color:#fff;">Reported Description:</span> '.$dfs5['reported_description'].'';
}}
$jkk .= '<dt><span>'.$dfs2['description'].'</span><div class="acc-icon-wrap parallax-wrap"><div class="acc-button-icon parallax-element"><i class="fa fa-angle-down"></i></div></div></dt><dd class="accordion-content"><h4>Document Symbol</h4>'.$dfs2['document_symbol'].'<h4>National Legal Bases</h4>'.$dfs2['national_legal_bases'].''.$rop.'<h4>Relevance</h4><span style="color:#fff;">Date From:</span> '.$dfs2['period_from_dt'].' <span style="color:#fff;">Date To:</span> '.$dfs2['period_to_dt'].' <span style="color:#fff;">In Force</span> '.$dfs2['in_force_dt'].'<h4>Measures</h4>'.$jko4.'<h4>Products</h4>'.$jko3.'<h4>WTO Agreements</h4>'.$jko2.'';
}
return $jkk;
  • Вопрос задан
  • 47 просмотров
Пригласить эксперта
Ответы на вопрос 1
lenk0belk0
@lenk0belk0
программироваю
Вам нужен оператор .= в циклах.
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы