@ilovv
Нуб, нуждающийся в помощи в php

Как вывести этот json?

есть json:
"tasks": {
		"Введение": {
			"§ 1. Химия — часть естествознания": {
				"1": ["https://gdz-ru.com/attachments/images/tasks/000/049/476/0002/5d5270d21a65c.jpg", "https://gdz-ru.com/attachments/images/tasks/000/049/476/0000/5d52723a2059d.jpg"],
				"2": ["https://gdz-ru.com/attachments/images/tasks/000/049/476/0002/5d5270d21ad0b.jpg", "https://gdz-ru.com/attachments/images/tasks/000/049/476/0000/5d52723a26165.jpg"],
				"3": ["https://gdz-ru.com/attachments/images/tasks/000/049/476/0002/5d5270d21aed3.jpg", "https://gdz-ru.com/attachments/images/tasks/000/049/476/0000/5d52723a263a7.jpg"],
				"4": ["https://gdz-ru.com/attachments/images/tasks/000/049/476/0002/5d5270d21b108.jpg", "https://gdz-ru.com/attachments/images/tasks/000/049/476/0000/5d52723a264d5.jpg"],
				"5": ["https://gdz-ru.com/attachments/images/tasks/000/049/476/0002/5d5270d21b2f5.jpg", "https://gdz-ru.com/attachments/images/tasks/000/049/476/0000/5d52723a26623.jpg"],
				"6": ["https://gdz-ru.com/attachments/images/tasks/000/049/476/0002/5d5270d21b531.jpg", "https://gdz-ru.com/attachments/images/tasks/000/049/476/0000/5d52723a26786.jpg"],
				"7": ["https://gdz-ru.com/attachments/images/tasks/000/049/476/0002/5d5270d21b692.jpg", "https://gdz-ru.com/attachments/images/tasks/000/049/476/0000/5d52723a268ce.jpg"],
				"8": ["https://gdz-ru.com/attachments/images/tasks/000/049/476/0002/5d5270d21b7f4.jpg", "https://gdz-ru.com/attachments/images/tasks/000/049/476/0000/5d52723a26a3e.jpg"],
				"9": ["https://gdz-ru.com/attachments/images/tasks/000/049/476/0002/5d5270d21b94d.jpg", "https://gdz-ru.com/attachments/images/tasks/000/049/476/0000/5d52723a26b50.jpg"],
				"10": ["https://gdz-ru.com/attachments/images/tasks/000/049/476/0002/5d5270d21ab6c.jpg", "https://gdz-ru.com/attachments/images/tasks/000/049/476/0000/5d52723a25ee8.jpg"]
			},
			"§ 2. Предмет химии. Вещества": {
				"1": ["https://gdz-ru.com/attachments/images/tasks/000/049/476/0002/5d5270d21baaa.jpg", "https://gdz-ru.com/attachments/images/tasks/000/049/476/0000/5d52723a26c5a.jpg"],
				"2": ["https://gdz-ru.com/attachments/images/tasks/000/049/476/0002/5d5270d21bf0a.jpg", "https://gdz-ru.com/attachments/images/tasks/000/049/476/0000/5d52723a26dbf.jpg"],
				"3": ["https://gdz-ru.com/attachments/images/tasks/000/049/476/0002/5d5270d21c0cc.jpg", "https://gdz-ru.com/attachments/images/tasks/000/049/476/0000/5d52723a26f03.jpg"],
				"4": ["https://gdz-ru.com/attachments/images/tasks/000/049/476/0002/5d5270d21c245.jpg", "https://gdz-ru.com/attachments/images/tasks/000/049/476/0000/5d52723a27078.jpg"],
				"5": ["https://gdz-ru.com/attachments/images/tasks/000/049/476/0002/5d5270d21c3d9.jpg", "https://gdz-ru.com/attachments/images/tasks/000/049/476/0000/5d52723a271a2.jpg"],
				"6": ["https://gdz-ru.com/attachments/images/tasks/000/049/476/0002/5d5270d21c57d.jpg"],
				"7": ["https://gdz-ru.com/attachments/images/tasks/000/049/476/0002/5d5270d21c709.jpg"],
				"8": ["https://gdz-ru.com/attachments/images/tasks/000/049/476/0002/5d5270d21c8bb.jpg"],
				"9": ["https://gdz-ru.com/attachments/images/tasks/000/049/476/0002/5d5270d21ca56.jpg"],
				"10": ["https://gdz-ru.com/attachments/images/tasks/000/049/476/0002/5d5270d21bcd6.jpg"]
			}}

мне нужно его вывести в формате:
спойлер{
			спойлер{
				номер
			}
}

, но как это сделать на php?
есть еще один вариант:
json:
"tasks": {
		"Тема 1 (задания)": {
			"1": ["https://gdz-ru.com/attachments/images/tasks/000/050/046/0000/5d49321a57348.jpg"],
			"2": ["https://gdz-ru.com/attachments/images/tasks/000/050/046/0000/5d49321a714a7.jpg"],
			"3": ["https://gdz-ru.com/attachments/images/tasks/000/050/046/0000/5d49321a7162f.jpg"],
			"4": ["https://gdz-ru.com/attachments/images/tasks/000/050/046/0000/5d49321a717d2.jpg"],
			"5": ["https://gdz-ru.com/attachments/images/tasks/000/050/046/0000/5d49321a71963.jpg"],
			"6": ["https://gdz-ru.com/attachments/images/tasks/000/050/046/0000/5d49321a71b9c.jpg"],
			"7": ["https://gdz-ru.com/attachments/images/tasks/000/050/046/0000/5d49321a71ce3.jpg"],
			"8": ["https://gdz-ru.com/attachments/images/tasks/000/050/046/0000/5d49321a71e5f.jpg"],
			"9": ["https://gdz-ru.com/attachments/images/tasks/000/050/046/0000/5d49321a71fd4.jpg"],
			"10": ["https://gdz-ru.com/attachments/images/tasks/000/050/046/0000/5d49321a6f0da.jpg", "https://gdz-ru.com/attachments/images/tasks/000/050/046/0000/5d49321a6f372.jpg"],
			"11": ["https://gdz-ru.com/attachments/images/tasks/000/050/046/0000/5d49321a6f5db.jpg"],
			"12": ["https://gdz-ru.com/attachments/images/tasks/000/050/046/0000/5d49321a6f885.jpg"],
			"13": ["https://gdz-ru.com/attachments/images/tasks/000/050/046/0000/5d49321a6fad3.jpg"],
			"14": ["https://gdz-ru.com/attachments/images/tasks/000/050/046/0000/5d49321a6fd21.jpg"],
			"15": ["https://gdz-ru.com/attachments/images/tasks/000/050/046/0000/5d49321a70147.jpg"],
			"16": ["https://gdz-ru.com/attachments/images/tasks/000/050/046/0000/5d49321a7039c.jpg"],
			"17": ["https://gdz-ru.com/attachments/images/tasks/000/050/046/0000/5d49321a70750.jpg"],
			"18": ["https://gdz-ru.com/attachments/images/tasks/000/050/046/0000/5d49321a709ba.jpg", "https://gdz-ru.com/attachments/images/tasks/000/050/046/0000/5d49321a70f76.jpg"]
		}}

его я вывел так:
foreach ($json[tasks] as $key => $part) { ?>
					<div class="spoiler">
						<div class="spoiler-head"><?php echo $key?></div>
						<div class="spoiler-body book-content" id="<?php echo $key?>">
							<?php 
							foreach($part as $task => $link) {
								echo ('<a>'.$task.'</a>');
							}?>
						</div>
					</div>	
				<?php } ?>
  • Вопрос задан
  • 282 просмотра
Пригласить эксперта
Ваш ответ на вопрос

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

Похожие вопросы