Good afternoon.
My site runs on ISO-8859-1 encoding and when I pull data from an external XML, some characters return as a question mark.
I tried to convert with <?php header("Content-type: text/html; charset=utf-8"); ?>
but all the rest of the site like top, footer and other areas suffered with the coding change.
I've also added utf8_decode () and nothing solved.
Does anyone know of a solution to the problem?
A sample link link
<?php
$arquivo = "https://api.dino.com.br/v2/news/$id/mundo-do-marketing";
$info = file_get_contents($arquivo);
$lendo = json_decode($info);
echo '<pre>' . print_r($lendo, true) . '</pre>';
echo $lendo->Item->Summary;
$titulo = utf8_decode($lendo->Item->Title);
$autor = utf8_decode($lendo->Item->Author);
$retranca = utf8_decode($lendo->Item->Summary);
$data = date('d/m/Y', strtotime($lendo->Item->PublishedDate));
$categoria = utf8_decode($lendo->Item->Categories[0]->Name);
$conteudo = utf8_decode($lendo->Item->Body);
if($id == 108988){
redirect(base_url('noticias-corporativas'));
}
else{
?>
<h2><?php echo $titulo; ?></h2>
<p class="retranca-dino"><?php echo $retranca; ?></p>
<p class="autor-dino">Categoria: <span class="autor"><?php echo $categoria; ?></span></p>
<p class="autor-dino">Autor: <span class="autor"><?php echo $autor; ?></span></p>
<span class="data-dino">Data de Publicação: <span style="font-weight: normal;"><?php echo $data; ?></span></span>
<?php
if(empty($lendo->Item->Image->Url)){
echo NULL;
}
else{
$imagem = $lendo->Item->Image->Url;
?>
<div class="imagem-dino">
<img class="imagem" src="<?php echo $imagem; ?>" alt="<?php echo $titulo; ?>" title="<?php echo $titulo; ?>" />
</div>
<?php
}
}
?>
<div class="conteudo-dino"><?php echo $conteudo; ?></div>
<?php
echo br(1);
?>
Att.