Код ненанежный, но для примера годен.
function toHtml(array $content) {
$html = '';
foreach ($content as $row) {
if (is_string($row)) {
$html .= $row;
continue;
}
$attrs = '';
if (isset($row['attrs'])) {
foreach ($row['attrs'] as $name => $value) {
if ($row['tag'] === 'img') {
$value = '//telegra.ph' . $value;
}
$attrs .= sprintf(' %s="%s"', $name, $value);
}
}
$children = '';
if (isset($row['children'])) {
$children .= toHtml($row['children']);
}
$html .= sprintf('<%s%s>%s</%s>', $row['tag'], $attrs, $children, $row['tag']);
}
return $html;
}
$content = json_decode(
file_get_contents('https://api.telegra.ph/getPage/Vozmozhnosti-Telegram-03-30?return_content=true'),
true
);
echo toHtml($content['result']['content']);