$qan5 = '';
foreach ($data['results'] as $repository2):
$qan5 .= '<h3>'.$repository2['topic'][0].'</h3><h3>'.$repository2['question'].'</h3><h3>'.$repository2['answer'].'</h3>';
endforeach;
return $qan5;
foreach ($data['results'] as $repository2){
выводим топик
выводим вопрос
выводим ответ
}
кто мешает "foreach написать сначала" для топика, а потом выводить вопрос и ответ
я честно не понимаю этих затруднений.
какая проблема поместить одну часть кода над другой?
{
"total": 11,
"offset": 0,
"search_performed_at": "2022-03-29T16:49:14.996Z",
"results": [
{
"id": "ceab6560776af9ee4e41b37e15cbb3d96bf8c6b1",
"faq_id": "kaAt00000004DJZEA2",
"question": "I’m looking to finance my export transaction. What types of U.S. exporting loans are available?",
"answer": "Each year, numerous businesses benefit from export financing assistance. What about your business? The U.S. government can help with financing from the Small Business Administration, EXIM Bank, and U.S Department of Agriculture. Our export financing video and article spotlights these programs. ",
"first_published_date": "2016-03-28",
"last_published_date": "2018-02-26",
"url": "http://legacy.export.gov/article?id=I-m-looking-to-finance-my-export-transaction-What-types-of-U-S-exporting-loans-are-available",
"industry": [
"Export Management"
],
"topic": [
"Export Financing"
],
"country": [],
"trade_region": [],
"world_region": [],
"source": "ITA_FAQ"
},
{
"id": "54e563eff3cb2c8c86875ea9ffab90333592a6c4",
"faq_id": "kaAt00000004DJFEA2",
"question": "I’m preparing an export plan, what should I know about foreign import regulations?",
"answer": "When mapping your export strategy, be aware most countries have certain foreign import regulations to ensure safety, quality, and conformity. Also, will you need to adapt your product for the foreign market? Our Foreign Import Regulations and Export Documentation videos and article offers expert advice. ",
"first_published_date": "2016-03-28",
"last_published_date": "2018-02-26",
"url": "http://legacy.export.gov/article?id=I-m-preparing-an-export-plan-what-should-I-know-about-foreign-import-regulations",
"industry": [],
"topic": [
"Foreign Trade Regulations"
],
"country": [],
"trade_region": [],
"world_region": [],
"source": "ITA_FAQ"
} ... }
<dt><span>Имя</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"><h3>Question</h3><dd>Ты кто?</dd><h3>Answer</h3><dd>Вася</dd></div>
<dt><span>Возраст</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"><h3>Question</h3><dd>Сколько лет?</dd><h3>Answer</h3><dd>5</dd></div>
Подредактировал, но там логично что оно вывело когда это одним перебором забиралось
Я не могу использовать echo мне нужно что бы оно все ретурнило одной переменной